Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect a settings module as Django project type #15

chrishas35 opened this issue Dec 26, 2011 · 2 comments

Detect a settings module as Django project type #15

chrishas35 opened this issue Dec 26, 2011 · 2 comments


Copy link

@chrishas35 chrishas35 commented Dec 26, 2011

I have a project with the following structure (following the recent advice of BDFL @jacobian, slide 51)


Unfortunately, Heroku doesn't detect this as a Django project due to the fact that a file does not exist.

@kenreitz42 kenreitz42 closed this Dec 26, 2011
@kenreitz42 kenreitz42 reopened this Dec 26, 2011
Copy link

@kenreitz42 kenreitz42 commented Dec 26, 2011

Thanks for the feedback. This isn't the first time someone's asked us to support this. We'll keep it in mind.

Luckily, it is recognized as a regular Python application, and will work properly if you configure it. You'll just have to add a few lines to get the database info from the environment in your settings.

Copy link

@chrishas35 chrishas35 commented Dec 26, 2011

Ahh, yes...I logged it and then decided to start hacking for a solution. Thanks for the tip and for including the relevant info in an environment variable.

For others who may come across this, the workaround is to add the following to the settings file being used:

# Manually inject Heroku settings due to lack of a file
# Issue logged

import os
import sys
import urlparse


    # Check to make sure DATABASES is set in file.
    # If not default to {}

    if 'DATABASES' not in locals():
        DATABASES = {}

    if 'DATABASE_URL' in os.environ:
        url = urlparse.urlparse(os.environ['DATABASE_URL'])

        # Ensure default database exists.
        DATABASES['default'] = DATABASES.get('default', {})

        # Update with environment configuration.
            'NAME': url.path[1:],
            'USER': url.username,
            'PASSWORD': url.password,
            'HOST': url.hostname,
            'PORT': url.port,
        if url.scheme == 'postgres':
            DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

        if url.scheme == 'mysql':
            DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
    print 'Unexpected error:', sys.exc_info()
@kenreitz42 kenreitz42 closed this Dec 26, 2011
podshumok pushed a commit to podshumok/heroku-buildpack-python that referenced this issue Dec 19, 2012
Add version to the sample package.json shown in README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants