Reputation: 171
It shows that tables are successfully created when I do heroku run -a "app-name" python manage.py migrate
Running python manage.py migrate on ⬢ app_name... up, run.0000 (Free)
System check identified some issues:
...
Operations to perform:
Apply all migrations: admin, auth, blog, contenttypes, home, sessions, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
...
But when I create a superuser, it tells me that there is no table Any suggestions? I’m sticking in it for 3 days now so I will be grateful for any help.
P.S. I use heroku postgresql hobby-dev.
P.P.S.
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 423, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: auth_user
Base settings.py https://pastebin.com/DLh3KrK7
My production configuration (settings.py
)
from .base import *
import dj_database_url
import environ
DEBUG = False
try:
from .local import *
except ImportError:
pass
environ.Env.read_env()
env = environ.Env()
DATABASES = {
'default': env.db()
}
Upvotes: 0
Views: 424
Reputation: 25227
Re-check your database configuration. The error trace shows that it's using sqlite as the database backend, instead of Postgres as expected:
File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/sqlite3/base.py", line 423, in execute
This is then failing because the sqlite database is stored on the filesystem, and filesystems on Heroku are not persistent across commands - so the database you created in the migrate
step no longer exists when you run createsuperuser
.
Upvotes: 2
Reputation: 790
please run these command
python manage.py syncdb
python manage.py migrate
python manage.py createsuperuser
please make sure that you in your installed app
'django.contrib.auth'
and tell me if you still got the same error and then please add your settings.py
Upvotes: 0