Questions about Heroku and Django settings
Question: I have tried many, many times to get my apps running on Heroku without
success. The fact that they run locally seems to be totally irrelevant.
Clearly I don’t understand how this works.

So … here are a couple of questions, which I've decided to group to gether in
a single question on SO:

**1.** Why does Heroku have so many different places that influence the
settings (Procfile, wsgi.py, config vars, and settings.py)?

**2.** How do they relate to one another?

**3.** Which has precedence?

**4.** Do they all have to be exactly the same?

**5.** What am I supposed to do with / how am I supposed to configure the
database settings given in the Heroku Django template?

>   78. # Parse database configuration from $DATABASE_URL
>   79. DATABASES['default'] = dj_database_url.config()
>   80. # this line blank in original. I put text here to make it format
> correctly
>   81. # Enable Connection Pooling (if desired)
>   82. DATABASES['default']['ENGINE'] = 'django_postgrespool'
>

**a)** Doesn’t DATABASE [‘ENGINE’], coming after DATABASE [default] overwrite
DATABASE [default]?

**b)** Why aren’t these two in the same format as the default Django settings,
which is a simple dictionary, instead of all these extra and confusing
brackets?

**c)** Are they supposed to be treated as two different settings, so that you
have to use database routers if you want both?

**d)** Why does the [devcenter
article](https://devcenter.heroku.com/articles/python-concurrency-and-
database-connections) say to import postgrespool but the
[template](https://github.com/heroku/heroku-django-template) says nothing
about that?

**e)** Why is ‘default’ [optional](https://github.com/kennethreitz/dj-
database-url) with dj_database_url but
[mandatory](https://docs.djangoproject.com/en/1.7/ref/settings/#databases)
with Django?

**f)** When I tried commenting out line 82, I got an error about resetting
queries, why?

**g)** I have the postgres string from my config vars as the argument to
dj_database_url, but I get a NAME ERROR, database undefined. Why?


Answer: You're making this much much much more difficult than it actually is. All
`dj_database_url` does is use an environment variable to create a dictionary
suitable for use in the DATABASES setting. It doesn't do anything else.

The devcenter article you link to mentions processpool as a way of increasing
concurrency. It doesn't say or even hint that you need it when you're starting
out. There is no reason for you to even be reading that article at this point.

The only article you need to read is the [Getting started with
Django](https://devcenter.heroku.com/articles/getting-started-with-django)
one, which tells you _exactly_ what to do.

