[Django]-Django with Postgresql on Heroku – settings.DATABASES is improperly configured. Please supply the NAME value

3👍

I want to help you and I give you here what you could change to make it wok but I cannot promise anything. I know you are now trying quite a long time to make that app run.

Make it run local

Change the DATABASES to the following:

DATABASES = {
 "default": 
 {
  "ENGINE": "django.db.backends.postgresql_psycopg2", #one of those should work
  'ENGINE': 'django.db.backends.postgresql',   #one of those should work
  "NAME": 'myProject',
  "HOST": "localhost", 
  "PORT": "5432",
 }
 }

Of course only choose one Engine and comment the other one out.

You can also try to access your DB over a desktop application like PSequel there you can login to your db with the given parameters.

Directly take the Heroku DB

Heroku provides a DB when you initialize a Project. You should have a Postgres Add-on. go to that link “https://dashboard.heroku.com/apps/YourAppName/settings” (the settings page ob your app on Heroku.com) and there you got the point “Config Variables” click on the button next to it. There should pop out a field with DATABASE_URL copy the link next to it with the format postgres://fasdfsdafsadfdsafsdafsda:123123132132123asdfdsafdssafdsfdaasdfsadf2-321-21-312-321.casdte-1.amazonaws.com:5432/adsdasdasads123
NOTE! Never give that link to anybody!

now you can use in your settings.py

  import dj_database_url 
  DATABASES = {'default': dj_database_url.parse('postgres://the-just-copied-link-comes-here

With that in your settings.py you have the Heroku DB in the Project. Its very slow for development but you need to send it do it this way when you push the code to Heroku. Don’t forget to install dj_database_url if don’t have it. Package

I hope that brings you a step closer to your goal.

in settings.py

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
MAILER_LIST = ['yourMail@gmail.com']
EMAIL_HOST = ' smtp.gmail.com'
EMAIL_HOST_USER = 'Name'
EMAIL_HOST_PASSWORD = 'lalalala'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'root@localhost'
ADMINS = [("Name", 'Mail@gmail.com')]
LOGGING = {
     'version': 1,
     'disable_existing_loggers': False,
     'handlers': {
         'mail_admins': {
             'level': 'ERROR',
             'class': 'django.utils.log.AdminEmailHandler' }},
     'loggers': {'django.request': {
             'handlers': ['mail_admins'],
             'level': 'ERROR',
             'propagate': True, },}}

You also don’t have to do that now but with this you can see the errors you are getting on heroku in the logging section. There you have the traceback and can figure out why your fronted isn’t working ( right now im guessing its a 404 with some static files). Tell me when you wrote your next question 😉 Get to logs from your heroku app https://dashboard.heroku.com/apps/YourAppName/logs

0👍

I ran into a similar problem and was able to deploy a django app to heroku using the following process:

  1. I created a new heroku app in my project’s directory and pushed the code.
  2. At this point, heroku detected that my app was a django app which used postgres, so it automatically added the postgres addon. If your app doesn’t do this, you can manually add the heroku postgresql addon.
  3. Now, the key step is to get the configuration information from heroku’s instance of postgres and add it to the settings.py file in the django app. To do this, go to https://dashboard.heroku.com/apps//resources . “Heroku Postgres :: Database” should be listed under the “add-ons” section. Click on that.
  4. This will take you to the page for the “Heroku Postgresql” addon. Click on the “Settings” tab. Click the “View Credentials…”. This will open a screen with config. information about the postgres instance.
  5. Copy these values (things like host, user, port, password, etc.) into the settings.py file in your django app and push it to heroku. Specifically to your question, the “Database” entry in this section provides the name of the database.
  6. Cross your fingers and hope for the best!

As described here, this can all be done programatically via the CLI.

👤Floyd

Leave a comment