Django2 Database Settings (ENGINE VALUE) and Heroku Administration Screen Login

Asked 2 years ago, Updated 2 years ago, 164 views

I am creating a blog project in Django 2.0.The database was changed from the default SClite3 to PostgreSQL and deployed to Heroku.
As I can no longer log in from the management screen on the Heroku site, I am writing to ask you how to resolve this issue.

As for the work I've done, I've looked up various sites and found out about settings.py's

DATABASES={
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3',
    }
}

This is

import dj_database_url
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
db_from_env = dj_database_url.config()
DATABASES = {
        'default': dj_database_url.config()
}
ALLOWED_HOSTS=['*']

After this replacement deployment, $heroku open successfully displayed the site.
$python manage.py create superuser to
superuser before deployment I created an account and set a password.
In your local environment, this login information is valid and you can log in and post a blog from the administration screen.

However, https:****.herokuapp.com/admin
When I tried to log in from the Administration screen, I could not log in with user information that was enabled locally.
I looked into various things again and found out that I need to create a superuser account again.
And I ran $python manage.py create superuser again.

settings.DATABASES is optimally configured.Please supply the ENGINE value.

↑ This error has occurred.

I haven't tried it yet, but if you write down DATABASES below, it will be
Can I run create superuser and log in from the Heroku site as a management screen?

import dj_database_url
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
db_from_env = dj_database_url.config()
DATABASES = {
        'default': {  
       'ENGINE': 'django.db.backends.postgresql'
            'NAME': dj_database_url.config()
         }
}
ALLOWED_HOSTS=['*']

Or, I would appreciate it if you could let me know if there are any other causes or methods.
Do you need any PostgreSQL settings from the Heroku dashboard?
Thank you for your cooperation.

django heroku postgresql

2022-09-30 21:32

1 Answers

I solved myself.Create superuser failed due to an elementary command error.

Correctly
$ herokurun python manage.py create superuser
However, I forgot to turn on herokurun.
$ python manage.py createsupseuser
has been running many times.

You can now successfully log in from heroku.app/admin.
Sorry for the trouble.


2022-09-30 21:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.