10

I've decided to play around a bit with Django (since I've heard so much about it). I'm walking through the tutorial here:

http://docs.djangoproject.com/en/1.2/intro/tutorial01/#intro-tutorial01

about halfway through the tutorial, i'm asked to run this from my command line:

python manage.py syncdb

However, I'm getting this error:

C:\django-projects\mysite>python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager
    utility.execute()
  File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line 257, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "C:\Python25\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "C:\Python25\lib\site-packages\django\core\management\commands\syncdb.py", line 7, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "C:\Python25\lib\site-packages\django\core\management\sql.py", line 5, in <module>
    from django.contrib.contenttypes import generic
  File "C:\Python25\lib\site-packages\django\contrib\contenttypes\generic.py", line 6, in <module>
    from django.db import connection
  File "C:\Python25\lib\site-packages\django\db\__init__.py", line 75, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "C:\Python25\lib\site-packages\django\db\utils.py", line 91, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Python25\lib\site-packages\django\db\utils.py", line 32, in load_backend
    return import_module('.base', backend_name)
  File "C:\Python25\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
ValueError: Empty module name

here is the relevant part of my setup.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'c:/python25/ramysDB',                      # 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.
    }
}
2
  • 3
    Remove the last period so ENGINE is 'django.db.backends.sqlite3'. I hope that works for you. Commented Aug 2, 2010 at 2:29
  • As Ricky says, just: "You can name it anything. I usually name mine 'dev.db' (no file path) for local development" It worked for me Commented Sep 6, 2011 at 17:31

4 Answers 4

14

I got this error because of a non-existent Django app name listed in settings.py, which, in our case, was the empty string:

INSTALLED_APPS = (
...
''
)

Removing that one line solved the problem.

Sign up to request clarification or add additional context in comments.

Comments

6

It looks like you don't have your database configured right. Check your settings.py and make sure you have a valid database ENGINE defined:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # 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.
    }
}

You probably want django.db.backends.sqlite3? And set a NAME for it.

Update:

You have an extra period in ENGINE. Change it to 'django.db.backends.sqlite3'. Hope that helps.

6 Comments

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'c:/python25/ramysDB', # 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. } }
that's my setup. here's the bit i don't get from the tutorial: "If you're using SQLite, you don't need to create anything beforehand - the database file will be created automatically when it is needed." what, then, should the NAME parameter look like? should i have a path to a file or just a path to a directory like I have? What would the file extension be if I do put a filename there?
You can name it anything. I usually name mine 'dev.db' (no file path) for local development.
BTW, that will place the database file in your project directory (where you run ./manage.py from). Oh, I think you have an extra period at the end of your ENGINE. change it to 'django.db.backends.sqlite3'. I bet that is it.
got it. not sure if it was the extra '.' or the dev.db. either way, seems to be working now. thanks, Ricky! _Ramy
|
0

Add app name at "INSTALLED_APPS" in settings.py

Comments

0

Removing an empty string from

INSTALLED_APPS = [
    'blog.apps.BlogConfig',
    'users.apps.UsersConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    '' <-- This one
]

Also worked for me too

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.