[Django]-Django loaddata settings error

8👍

Don’t use django-admin.py for anything other than setting up an initial project. Once you have a project, use manage.py instead – it sets up the reference to your settings file.

3👍

syncdb will load content_types, you need to clear that table before loading data. Something like this:

c:\> sqlite3 classifier.db
sqlite> delete from django_content_type;
sqlite> ^Z
c:\> python django-admin.py loaddata dumpdata.json

Also, make sure you do not create a superuser, or any user, when you syncdb, as those are likely to also collide with your data fixture …

1👍

There are two standard ways to provide your settings to Django.

  • Using set (or export on Unix) set DJANGO_SETTINGS_MODULE=mysite.settings
  • Alternatively as an option with django-admin.py --settings=mysite.settings

Django-config does things differently because it allows you to have multiple settings files. Django-config works with manage.py to specify which to use. You should use manage.py whenever possible; it sets up the environment. In your case try this where –settings points to the specific .py file you want to use from django-config’s config folder.

django-admin.py loaddata dumpdata.json --settings=<config/settings.py>

Actually –settings wants python package syntax so maybe <mysite>.config.<your settings>.py

Leave a comment