Search code examples
djangobashheroku

user table not created on django deployment but superuser created on heroku bash


I'm trying to upload my first django app and I've been struggle with this issue for sometime, help is appreciated.

I already set up my project to be on heroku, I followed this tutorial: https://www.youtube.com/watch?v=6DI_7Zja8Zc in which django_heroku module is used to configure DB, here is the link to library https://pypi.org/project/django-heroku/

The app throws the error on login as if user tables didn't exist but I already create a super user using the heroku bash feature, after apply migrations using "heroku run python manage.py migrate". When I run "ls" command on heroku bash this is my directory:

manage.py Procfile requirements.txt runtime.txt smoke staticfile

"smoke" is my folder app, should I could see the db in this directory? if the db was not created how could I create a superuser using heroku bash feature?

This is the DB configuration that django gives me on server:

{'default': {'ATOMIC_REQUESTS': False,
             'AUTOCOMMIT': True,
             'CONN_MAX_AGE': 0,
             'ENGINE': 'django.db.backends.sqlite3',
             'HOST': '',
             'NAME': PosixPath('/app/db.sqlite3'),
             'OPTIONS': {},
             'PASSWORD': '********************',
             'PORT': '',
             'TEST': {'CHARSET': None,
                      'COLLATION': None,
                      'MIGRATE': True,
                      'MIRROR': None,
                      'NAME': None},
             'TIME_ZONE': None,
             'USER': ''}}  

I see that db is sqlite3 and should be postgreSQL but I understand that django-heroku library should do that.

I don't know what other information could be useful because I have no experience deploying nothing so I will be pending on more information request to edit this question.

My gitignore file is this:

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
#   For a library or package, you might want to ignore these files since the code is
#   intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# poetry
#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
#   This is especially recommended for binary packages to ensure reproducibility, and is more
#   commonly ignored for libraries.
#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

This is the bottom of my settings.py file:

...

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfile')

STATIC_URL = '/static/'

django_heroku.settings(locals())

Thank you.


Solution

  • If you look at the django-heroku repository on GitHub I think you'll find that it has been abandoned. It has a banner saying

    This repository has been archived by the owner. It is now read-only.

    and has not had a new commit on the master branch since October, 2018.

    The heroku-on-django library aims to be an updated replacement for django-heroku:

    This has been forked from django-heroku because it was abandoned and then renamed to django-on-heroku because old project has been archived.

    It is also somewhat stagnant (the most recent commit to master at the time of writing is from October, 2020) but it should work better than django-heroku.

    In either case, make sure to put this at the bottom of your settings.py as indicated in the documentation:

    # Configure Django App for Heroku.
    import django_on_heroku
    django_on_heroku.settings(locals())