Problems with PyCharm Django example


I'm new to PyCHarm/Django and may be asking a simple question, but I'm having trouble getting the Django example (on polls) to work.

I have the latest versions of both PyCharm and Django.

The first problem is that when I follow the instructions to create a Django Project, my directory structure differs from the one shown in the example.

The example ( has this structure.










I get





As you can see, there are two files and two files.  Why is that, and which one should I use?

In fact, I tried both of them. It seems that the one nested under MyDjangoApp/MyDjangoApp is the one to use. I say that because of a second problem.

I have no problem validating the models or running the server (with runserver), but when I actually run the project I get an error page. Instead of the administrative interface ( I get the following page.

It worked!

Congratulations on your first Django-powered page.

Of course, you haven't actually done any work yet. Here's what to do next:

  • If you plan to use a database, edit the DATABASES setting in MyDjangoProject/
  • Start your first app by running python startapp [appname].

You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

When I set the DEBUG to False in the second file, I still get that page. When I set DEBUG to False in the first page I get a simpler error page: "A server error occurred.  Please contact the administrator."

So it seems that the first page is the relevant one. But why can't I reach the database? I have edited the file file as instructed.

# Django settings for MyDjangoProject project.

DEBUG = False



    # ('Your Name', ''),




    'default': {

        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

        'NAME': 'MyDatabase',                      # Or path to database file if using sqlite3.

        'USER': '',                      # Not used with sqlite3.

        'PASSWORD': '',                  # Not used with sqlite3.

        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.

        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.



But The system can't find the database.
Any help would be appreciated.
Comment actions Permalink

I tried the same thing on a different computer and ran into a different problem.

This time the directory structure was again not the same as in the tutorial. It was the same as in my first message but without the extra files at the bottom.






The error is that when I run it I get a yellow error screen with the following.

Exception Value:
No module named polls.models
Exception Location: C:\Users\facuser\PycharmProjects\MyDjangoApp\polls\ in <module>, line 3

It's true that line 3 of refers to polls.models. (from MyDjangoApp.polls.models import Poll, Choice)

But the file MyDjangoApp\polls\ is in place. Why is it not seen as a module?


Comment actions Permalink

I found the answer. I started to run through the Django version of the same app. It explained that the outer MyDjangoApp was meaningless and was just a container for the project. The project itself is polls and one refers to its elements as polls.<whatever> -- but not MyDjangoApp.polls.<whatever>  The admin line that imports from MyDjangoApp.polls.models should really just import from polls.models. When I made that change, the admin site appeared.

The Django site also explained that the directory structure changed in version 1.4, which explains why it did not match the structure in the PyCharm tutorial.


Please sign in to leave a comment.