0

I'm trying to create my django app w/ Heroku however I'm stuck on this error. I have seen some information on heroku not being able to use sqllite so I've been trying to update to postgres but not sure why that's not reflected here.

sqlite3.OperationalError: no such table: auth_user

heroku run python3 manage.py createsuperuser

 ›   Warning: heroku update available from 7.41.0 to 7.60.1.
Running python3 manage.py createsuperuser on ⬢ generic-heroku-app... up, run.5883 (Free)
On development database

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 423, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: auth_user

DB from settings.py

import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '**',
        'USER': '**',
        'PASSWORD': '**',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

Edit: this thread shows some solid info but I still can't seem to make it work with this info. Not sure where I'm going wrong.. "no such table" error on Heroku after django syncdb passed

Any help would be greatly appreciated!

Tai
  • 1
  • 4
  • You need to run your migrations `python manage.py migrate ` – Iain Shelvington Apr 19 '22 at 01:20
  • `python3 manage.py migrate On development database Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: No migrations to apply.` – Tai Apr 19 '22 at 01:31
  • this is what I get when i run that ^^. I've migrated everything and pushed to git but keep running into this. – Tai Apr 19 '22 at 01:31
  • The migrations haven't been applied to whatever database you are running the `createsuperuser` command against, you can see in the output `You have 18 unapplied migration(s) ` – Iain Shelvington Apr 19 '22 at 01:32
  • Yupp, how can I apply those correctly tho? – Tai Apr 19 '22 at 01:34
  • However or wherever you ran that `createsuperuser` command, you need to run migrations in the same environment. I assume the command would be `heroku run python3 manage.py migrate` – Iain Shelvington Apr 19 '22 at 01:37
  • just tried that and still getting the same error.. – Tai Apr 19 '22 at 01:41
  • When I run `python3 manage.py createsuperuser ` locally it runs fine. I'm also able to stand up the app on localhost without any problems. It's just this stage... – Tai Apr 19 '22 at 02:02

1 Answers1

0

If your project is connected with github deploy, then in your project, in Procfile, add:

release: python manage.py migrate
web: gunicorn myproject.wsgi
  • This is currently what I have: `web: gunicorn django_local_library.wsgi --log-file - release: python manage.py migrate`. Is there something else I'm missing? – Tai Apr 19 '22 at 02:36
  • What is your version of django? Why aren't you using 'django.db.backends.postgresql' instead of 'django.db.backends.postgresql_psycopg2'? – Lucas Moreira Apr 19 '22 at 11:38
  • Django version == 3.2.13. I'm new to Django so following tutorials of what other people are doing online. Will that solve this error? @Lucas – Tai Apr 19 '22 at 15:12
  • Because it is a study, I suggest you use another tutorial. I believe it will be more beneficial for you. – Lucas Moreira Apr 19 '22 at 22:51
  • that's not helpful... There's no tutorial for why this error is occurring for a locally functional django application. You should try to add helpful information. – Tai Apr 20 '22 at 05:01
  • @Tai can you put your code into an github reporitory and share the link with us? – Lucas Moreira Apr 20 '22 at 21:51
  • https://github.com/tfurbs/django_local_library it's right here! – Tai Apr 21 '22 at 04:25