python - Django superuser fixture error - no such table: auth_user -


i want define fixed username , password superuser creation in django's syncdb (after has been executed). method i'm using below working in older version of django (i guess 1.6) it's not working.

i have fixture file initial_data.json :

[ {   "fields": {     "username": "me",     "first_name": "",     "last_name": "",     "is_active": true,     "is_superuser": true,     "is_staff": true,     "last_login": null,     "groups": [],     "user_permissions": [],     "password": "pbkdf2_sha256$...",     "email": "a@a.co",     "date_joined": "2015-04-23t01:13:43.233z"   },   "model": "auth.user",   "pk": 1 } ] 

when add in settings.installed_apps:

installed_apps = (     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.messages',     'django.contrib.staticfiles',     'my_app',  ) 

and run python manage.py syncdb, following error :

django.db.utils.operationalerror: problem installing fixture 'path/initial_data.json': not load auth.user(pk=1): no such table: auth_user 

what should do?

can change order fixtures load ensure auth_user table created before fixture loaded?

or other way automatically create superuser in django?

thanks in advance.

i solved problem, not prettiest solution.

i saw when run heroku run python manage.py syncdb, following

operations perform:   synchronize unmigrated apps: myproject, permissions, myapp1, myapp2   apply migrations: auth, flatpages, admin, contenttypes, sessions, sites synchronizing apps without migrations:   creating tables...     creating table app1_model1     creating table app1_model2     ... 

so thought if migrate included apps in reverse order :

heroku run python manage.py migrate sites; heroku run python manage.py migrate sessions; heroku run python manage.py migrate contenttypes; heroku run python manage.py migrate admin; heroku run python manage.py migrate flatpages; heroku run python manage.py migrate auth; 

and worked! have no idea why, did. maybe else too.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -