GithubHelp home page GithubHelp logo

heroku / heroku-django-template Goto Github PK

View Code? Open in Web Editor NEW
904.0 119.0 388.0 71 KB

A Django 2.0 base template featuring all recommended best practices for deployment on Heroku and local development.

Home Page: https://www.heroku.com/python

Python 100.00%
django python heroku whitenoise starter-template gunicorn heroku-django-template

heroku-django-template's People

Contributors

acbalingit avatar akshaybabloo avatar bradshjg avatar dshabin avatar edsfocci avatar eluttner avatar erictheise avatar evansd avatar fanquake avatar jeasoft avatar kennethreitz avatar lepistone avatar mokutsu avatar neosergio avatar rminderhoud avatar sesh avatar tdaglis avatar theeluwin avatar trakjohnson avatar travisjungroth avatar vamsi avatar yothinix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

heroku-django-template's Issues

Problem deploying with runtime 3.6.0

I have a problem deploying this template using runtime 3.6.0. I've never had this problem before and when I change back to 3.5.0, it works fine. Any ideas?

heroku-django-template-fail

Problem with collectstatic with djangorestframework==3.6.0 or 3.6.1 and whitenoise==3.2 or 3.3

When I tried to deploy in heroku a project with djangorestframework>=3.6.0 I got this error
-----> Python app detected -----> Installing requirements with pip Collecting djangorestframework==3.6.0 (from -r /tmp/build_7659bf556ac45b456a1b91407a022c10/projectname-e014b5a/requirements/base.txt (line 5)) Downloading djangorestframework-3.6.0-py2.py3-none-any.whl (1.2MB) Installing collected packages: djangorestframework Found existing installation: djangorestframework 3.5.3 Uninstalling djangorestframework-3.5.3: Successfully uninstalled djangorestframework-3.5.3 Successfully installed djangorestframework-3.6.0 $ python manage.py collectstatic --noinput Post-processing 'rest_framework/docs/css/bootstrap-theme.min.css' failed! Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle collected = self.collect() File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 145, in collect raise processed whitenoise.storage.MissingFileError: The file 'rest_framework/docs/css/../fonts/glyphicons-halflings-regular.eot' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f8e7dffd750>. The CSS file 'rest_framework/docs/css/bootstrap-theme.min.css' references a file which could not be found: rest_framework/docs/css/../fonts/glyphicons-halflings-regular.eot Please check the URL references in this CSS file, particularly any relative paths which might be pointing to the wrong location. ! Error while running '$ python manage.py collectstatic --noinput'. See traceback above for details. You may need to update application code to resolve this error. Or, you can disable collectstatic for this application: $ heroku config:set DISABLE_COLLECTSTATIC=1 https://devcenter.heroku.com/articles/django-assets ! Push rejected, failed to compile Python app. ! Push failed

I think problem could be related to glyphicons but I'm not sure. I was able to deploy successfully with djangorestframework==3.5.4 (or lower) and whitenoise (3.2 or 3.3)

Push faied when git push heroku master

MacOS Sierra 10.12.6 Python3.6.4 Django 2.0.4

$git push heroku master
Counting objects: 6352, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5341/5341), done.
Writing objects: 100% (6352/6352), 6.76 MiB | 307.00 KiB/s, done.
Total 6352 (delta 1891), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.4 (you are using Python-3.6.4, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.4).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing Python-3.6.4
remote: ! Requested runtime (Python-3.6.4) is not available for this stack (heroku-16).

remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to gentle-reaches-31834.
remote:
To https://git.heroku.com/gentle-reaches-31834.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/gentle-reaches-31834.git'

As above, heroku recommends using python3.6.4,and I am using pyhon3.6.4, I researched the articles/python_support, did as it advise,but push still faied... help!help!help!๐Ÿ˜ณ

Need support for local development (Cloud9)

The README works great for deployment to Heroku.

However, if I run the app in local (C9 IDE in my case), I'm getting nowhere.

First I had to install all the requirements through pip install -r requirements.txt

Now, whitenoise is throwing this error:

django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

I guess, there'll be more errors while running in local. Could you please provide instructions for local environment setup?

Delete django-postgrespool as dependency and update settings.py

I've tried to setup my django project to heroku, but I've spend almost an hour resolving this bug.
https://github.com/kennethreitz/django-postgrespool/issues/24
As it turned out, simple resolution is to remove posgrespool as engine. It is old, probably unmaintained, unnecessary and you don't use it even in tutorial https://devcenter.heroku.com/articles/getting-started-with-django .
PS: Since 1.6 has connection pooling built in, so this library is totally useless

Build error

Two lines of code in settings.py

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

gives me a build error with the following trackback

File "manage.py", line 22, in <module>
           execute_from_command_line(sys.argv)
         File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
           utility.execute()
         File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 302, in execute
           settings.INSTALLED_APPS
         File "/app/.heroku/python/lib/python3.5/site-packages/django/conf/__init__.py", line 55, in __getattr__
           self._setup(name)
         File "/app/.heroku/python/lib/python3.5/site-packages/django/conf/__init__.py", line 43, in _setup
           self._wrapped = Settings(settings_module)
         File "/app/.heroku/python/lib/python3.5/site-packages/django/conf/__init__.py", line 99, in __init__
           mod = importlib.import_module(self.SETTINGS_MODULE)
         File "/app/.heroku/python/lib/python3.5/importlib/__init__.py", line 126, in import_module
           return _bootstrap._gcd_import(name[level:], package, level)
         File "<frozen importlib._bootstrap>", line 986, in _gcd_import
         File "<frozen importlib._bootstrap>", line 969, in _find_and_load
         File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
         File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
         File "<frozen importlib._bootstrap_external>", line 665, in exec_module
         File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
         File "/app/gollahalli_me/settings/__init__.py", line 16, in <module>
           from .production import *
         File "/app/gollahalli_me/settings/production.py", line 19, in <module>
           db_from_env = dj_database_url.config(conn_max_age=500)
       TypeError: config() got an unexpected keyword argument 'conn_max_age'
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, failed to compile Python app.
 !     Push failed

Now, to get over this problem I had to do this

DATABASES['default'] = dj_database_url.config()

I am not sure if others are able to reproduce this issue.

Update to Django 1.8?

Thanks for the template. Works great and makes it easy to deploy straight to Heroku!

Would you consider updating/revising the template to Django 1.8? Think it would be super useful.

Mention Python 3

This template should explain how to use it in Python 3 (namely, by modifying the runtime.txt file).

Error When Pushing to Heroku

I'm not really sure if this is a bug or perhaps something wrong with the way I'm doing things, but I've been following along with the Django doc's beginner tutorial, and at random points when I push to heroku, I get the following error: App not compatible with buildpack: https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
Any idea why this may be happening?

Missing License

The project is missing clear attribution to Django and a clear license.
I assume you'll use BSD https://github.com/django/django/blob/master/LICENSE but this project neither attributes Django appropriately nor licenses itself as an opensource project.

I would recommend that heroku merges the django license into this project and add Heroku in the copyright part of the license.

socket error

Hi,

When trying to create a new django app (using django-admin.py startproject --template=https://github.com/heroku/heroku-django-template/archive/master.zip --name=Procfile helloworld) I receive the following error:

CommandError: couldn't download URL https://github.com/heroku/heroku-django-template/archive/master.zip to master.zip: [Errno socket error] [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)

I haven't been able to figure out why. I am on a Mac. Thanks so much!

SSL certificate verify failed on startproject

Django 1.11.6
Python 3.6.2
pip 9.0.1
OSX 10.12.6

$ django-admin.py startproject --template=https://github.com/heroku/heroku-django-template/archive/master.zip --name=Procfile myApp
CommandError: couldn't download URL https://github.com/heroku/heroku-django-template/archive/master.zip to master.zip: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748)>

I see an issue with the same error message in pip here but I'm currently unsure if it's related. Help is appreciated and I will post a solution if/when I find one.

.env should not be in version control

Heroku documentation recommends that the .env file not be included in version control. This template does not follow that recommendation.

Instead, I suggest renaming .env to .env.example in this repo, and modifying .gitignore to include the line /.env.

dj_database_url breaks local syncdb with SQLite

The current settings database code...

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

# Parse database configuration from $DATABASE_URL
DATABASES['default'] =  dj_database_url.config()

# Enable Connection Pooling (if desired)
DATABASES['default']['ENGINE'] = 'django_postgrespool'

...does not work locally because DATABASES['default'] blows away ENGINE and NAME. dj_database_url is supposed to fill them back in, but it can't understand what NAME is supposed to be when run locally. The error when running syncdb:

settings.DATABASES is improperly configured. Please supply the NAME value.

Instead, DATABASES should try to use dj_database_url and read in a default with SQLite when run locally, and not use DATABASES['default'] or DATABASES['default']['ENGINE']:

DATABASES = {
    'default': dj_database_url.config(
        default='sqlite:////%s' % os.path.join(BASE_DIR, 'db.sqlite3')
    )
}

How one might still use DATABASES['default']['ENGINE'] = 'django_postgrespool' when only on Heroku, I'm not sure.

Is it 1.10 ready? (MIDDLEWARE vs MIDDLEWARE_CLASSES)?

I just realized that settings.py file still mentions 1.9. Also, this file is still using MIDDLEWARE_CLASSES settings - should be MIDDLEWARE from 1.10 on.

I'm wondering if you guys bumped version itself, but forgot to adjust settings.py.

TypeError: config() got an unexpected keyword argument 'require_ssl'

When I run python manage.py startapp appname, the TypeError in the subject of this issue is thrown.

Solution

I realized that in the settings.py file, had this line:

DATABASES['default'].update(dj_database_url.config(conn_max_age=500, require_ssl=True))

The require_ssl argument is actually supposed to be ssl_require basing on the the config() function in dj_database_url.py file of the dj-database-url package.

!!!!

I just wanted to say thank you. :)

Change the description

You might want to change the description of the repository from Django 1.11 to Django 2.0.

push ignoring commits while deploying existing project

Hi - I've got an existing Django app and repo ready to go to the internet and had been using Elastic Beanstalk but decided to try this on a whim. I've found it super intuitive and just need a bit of help getting over the finish line. Thank you for your help.

I added/adjusted/commited Procfile, requirements.txt, runtime.txt to my existing repo, but git push heroku master ignores these changes. I am on a local branch on my repository.

Here is the terminal. the pip freeze for the virtualenv ct and the requirements.txt have features=3.1.1 installed or listed. the runtime.txt file has python-2.7.13

[Please forgive the futzing with the remote branch.]

(ct) โžœ  database git:(feature/heroku) git push heroku master
Counting objects: 948, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (858/858), done.
Writing objects: 100% (948/948), 9.95 MiB | 234.00 KiB/s, done.
Total 948 (delta 568), reused 94 (delta 38)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote:  !     Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
remote:  !     Learn more: https://devcenter.heroku.com/articles/procfile
remote: -----> Installing python-3.6.3
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        Collecting awsebcli==3.0.10 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 1))
remote:          Downloading awsebcli-3.0.10.tar.gz (670kB)
remote:        Collecting backports-abc==0.5 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 2))
remote:          Downloading backports_abc-0.5-py2.py3-none-any.whl
remote:        Collecting cachetools==2.0.1 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 3))
remote:          Downloading cachetools-2.0.1-py2.py3-none-any.whl
remote:        Collecting cement==2.4.0 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 4))
remote:          Downloading cement-2.4.0.tar.gz (129kB)
remote:        Collecting certifi==2017.11.5 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 5))
remote:          Downloading certifi-2017.11.5-py2.py3-none-any.whl (330kB)
remote:        Collecting chardet==3.0.4 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 6))
remote:          Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting click==6.7 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 7))
remote:          Downloading click-6.7-py2.py3-none-any.whl (71kB)
remote:        Collecting Django==1.11.1 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 8))
remote:          Downloading Django-1.11.1-py2.py3-none-any.whl (6.9MB)
remote:        Collecting django-multiselectfield==0.1.8 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 9))
remote:          Downloading django-multiselectfield-0.1.8.tar.gz
remote:        Collecting futures==3.2.0 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 10))
remote:          Could not find a version that satisfies the requirement futures==3.2.0 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 10)) (from versions: 0.2.python3, 0.1, 0.2, 1.0, 2.0, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1)
remote:        No matching distribution found for futures==3.2.0 (from -r /tmp/build_5c8b5533bc92058e9ff43079e2217db4/requirements.txt (line 10))
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !	Push rejected to fast-shelf-91189.
remote: 
To https://git.heroku.com/fast-shelf-91189.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/fast-shelf-91189.git'
(ct) โžœ  database git:(feature/heroku) git remote rm heroku
(ct) โžœ  database git:(feature/heroku) git remote add heroku https://git.heroku.com/mysterious-stream-39208.git
(ct) โžœ  database git:(feature/heroku) git push heroku master                                                  
Counting objects: 948, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (858/858), done.
Writing objects: 100% (948/948), 9.95 MiB | 115.00 KiB/s, done.
Total 948 (delta 566), reused 94 (delta 38)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote:  !     Warning: Your application is missing a Procfile. This file tells Heroku how to run your application.
remote:  !     Learn more: https://devcenter.heroku.com/articles/procfile
remote: -----> Installing python-3.6.3
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        Collecting awsebcli==3.0.10 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 1))
remote:          Downloading awsebcli-3.0.10.tar.gz (670kB)
remote:        Collecting backports-abc==0.5 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 2))
remote:          Downloading backports_abc-0.5-py2.py3-none-any.whl
remote:        Collecting cachetools==2.0.1 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 3))
remote:          Downloading cachetools-2.0.1-py2.py3-none-any.whl
remote:        Collecting cement==2.4.0 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 4))
remote:          Downloading cement-2.4.0.tar.gz (129kB)
remote:        Collecting certifi==2017.11.5 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 5))
remote:          Downloading certifi-2017.11.5-py2.py3-none-any.whl (330kB)
remote:        Collecting chardet==3.0.4 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 6))
remote:          Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting click==6.7 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 7))
remote:          Downloading click-6.7-py2.py3-none-any.whl (71kB)
remote:        Collecting Django==1.11.1 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 8))
remote:          Downloading Django-1.11.1-py2.py3-none-any.whl (6.9MB)
remote:        Collecting django-multiselectfield==0.1.8 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 9))
remote:          Downloading django-multiselectfield-0.1.8.tar.gz
remote:        Collecting futures==3.2.0 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 10))
remote:          Could not find a version that satisfies the requirement futures==3.2.0 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 10)) (from versions: 0.2.python3, 0.1, 0.2, 1.0, 2.0, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.2.0, 3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1.0, 3.1.1)
remote:        No matching distribution found for futures==3.2.0 (from -r /tmp/build_dec194ff5cb572c321f281fbff2e25fb/requirements.txt (line 10))
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !	Push rejected to mysterious-stream-39208.
remote: 
To https://git.heroku.com/mysterious-stream-39208.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mysterious-stream-39208.git'

database setting

Why does the template use an assignment

DATABASES['default'] = dj_database_url.config()

instead of a dict as expected by the official docs ?https://docs.djangoproject.com/en/1.8/ref/settings/#databases

or even as given as an example on the (official?) dj-database-url web page?
https://warehouse.python.org/project/dj-database-url/

Does Heroku expect to be 'default'?
Is there no way to formulate this call to the function as a dict that works?

I'd like to submit a pull request depending on the response. Thanks.

HELP: Django 1.11

I can't seem to get Django 1.11 to work correctly on my own.
Can you guys update this template to use Django 1.11?

Thanks

Tested?

Hello, Kenneth,
Even though you have yet to respond to my emails, I am excited to see this new template. But I do still have questions:

  1. Has this been tested in production by anyone yet? What sort of results do they have, or are you looking for guinea pigs? If the latter, I will volunteer to be one, but that means you're going to have to talk to me sooner or later. ;-)
  2. Why are you (and I don't know if that's you personally, or Heroku) so reluctant to engage the multiple settings and requirements files model advocated by @rdegges and @pydanny?

push error: failed to detect app matching ... buildpack

Hello,

I'm trying to deploy this template on heroku.

It was first rejected with error "No default language could be detected for this app." So I followed the instruction on https://devcenter.heroku.com/articles/buildpacks about setting the buildback.

But the push was still rejected with error "Failed to detect app matching https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz buildpack".

The advice online is mostly about the requirements.txt and the Procfile, which are automatically included in this template.

Could you please let me know how to fix this?

Thank you!
Melanie

pipenv errors with the latest psycopg2

The latest psycopg2 v2.8 is giving me the following error when used as

pipenv install psycopg2

writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'", " Error: b'You need to install postgresql-server-dev-NN for building a server-side extension or libpq-dev for building a client-side application.\n'", ' ', ' ----------------------------------------']
[pipenv.exceptions.InstallError]: ['Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-hgl80c2q/psycopg2/']

I will stick with the 2.7.7 the last stable release that worked for me for now. Wondering if this was just me

Migration problem

Hi,

When trying to migrate using heroku run python manage.py migrate --app AppName, Heroku is asking is to install Pillow if your model has ImageField. I think this should be specified in the documentations.

Add settings for different envs

This project is an awesome starter for the heroku-based apps. Thanks!

Problem

But one thing caught my eye: there's only one configuration file for all possible envs: development, stage, testing, production and local.

Maybe it would be a good idea to add some kind of library to handle that? Some popular examples: django-configurations and django-split-settings.

Solution

Here's a brief example, how to use django-split-settings. We will need new settings package structure:

your_project/settings/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ components
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ database.py
โ”‚   โ”œโ”€โ”€ common.py
โ””โ”€โ”€ environments
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ development.py
    โ”œโ”€โ”€ local.py.template
    โ”œโ”€โ”€ production.py
    โ””โ”€โ”€ testing.py

And here's settings/__init__.py:

"""
This is a django-split-settings main file.
For more information read this:
https://github.com/sobolevn/django-split-settings

Default environment is `production`.
To change settings file:
`DJANGO_ENV=testing python manage.py runserver`
"""

from os import environ
from split_settings.tools import optional, include

ENV = environ.get('DJANGO_ENV') or 'production'  # since it's a production-ready template

base_settings = [
    'components/common.py',  # standard django settings
    'components/database.py',  # database setup
    
    # Select the right env:
    'environments/%s.py' % ENV,
    # Optionally override some settings:
    optional('environments/local.py'),
]

# Include settings:
include(*base_settings)

So after that it would be crystal-clear for users where to put extra configurations like: django-debug-toolbar and other which are used for development or testing only.

Conclusion

Pros:

  • Clear settings structure
  • No refactoring and no effect on the end user
  • Multiple possible environments with reasonable default

Cons:

  • Extra dependency

Maybe I am missing any cons, please correct me if I am wrong.

Further readings

Here's a detailed article I wrote on this topic: https://medium.com/wemake-services/managing-djangos-settings-e2b7f496120d


So, what do you think?

Turn into a cookiecutter

This is a great template, and I would love to see it benefit from the simplicity and features of Cookiecutter. Have you considered transforming it into one?

Whitenoise middleware included twice

Currently the whitenoise middleware gets included twice, because you are manually adding it into settings.py and calling django_heroku.settings without passing staticfiles=False (and therefore it gets added an other time by django-heroku).

Migration Error on local dev setup.

Running python manage.py migrate gives following error:

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Replacing this line:
DATABASES['default'] = dj_database_url.config(conn_max_age=500)
to:

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

Works.
Do let me know your thoughts.

error ( just added my virtual env folder to project directory)

screenshot from 2014-11-25 09 15 26

This error pops up while running my server manage.py

bash -cl "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/bin/python /home/tejesh/Apps/pycharm-3.4.1/helpers/pycharm/django_manage.py runserver /home/tejesh/PycharmProjects/heroku-django-template"
Traceback (most recent call last):
File "/home/tejesh/Apps/pycharm-3.4.1/helpers/pycharm/django_manage.py", line 23, in
run_module(manage_file, None, 'main', True)
File "/usr/lib/python2.7/runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/tejesh/PycharmProjects/heroku-django-template/manage.py", line 12, in
execute_from_command_line(sys.argv)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/core/management/init.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/core/management/init.py", line 238, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/core/management/init.py", line 41, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 14, in
from django.db.migrations.executor import MigrationExecutor
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 5, in
from .loader import MigrationLoader
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 8, in
from django.db.migrations.recorder import MigrationRecorder
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in
class MigrationRecorder(object):
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
class Migration(models.Model):
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 24, in Migration
app = models.CharField(max_length=255)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/models/fields/init.py", line 1012, in init
super(CharField, self).init(_args, *_kwargs)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/db/models/fields/init.py", line 146, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/conf/init.py", line 46, in getattr
self._setup(name)
File "/home/tejesh/PycharmProjects/heroku-django-template/django_heroku_env/local/lib/python2.7/site-packages/django/conf/init.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Process finished with exit code 1


THE BELOW ERROR SHOWS UP WHEN RUNNING

tejesh@tejesh-K53SM ~/PycharmProjects/heroku-django-template $ heroku run python manage.py syncdb
Running python manage.py syncdb attached to terminal... up, run.9438
Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/init.py", line 345, in execute
settings.INSTALLED_APPS
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/init.py", line 46, in getattr
self._setup(name)
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/app/.heroku/python/lib/python2.7/site-packages/django/conf/init.py", line 98, in init
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings '{{ project_name }}.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named {{ project_name }}.settings

Note: I use pycharm IDE

gzip manifest and gzip middleware

In the template, is this code

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

implementing gzip middleware? I tried googling to sort this out, but I don't understand enough about the basics to answer the question myself. This came up when I as setting up debug toolbar https://django-debug-toolbar.readthedocs.org/en/1.3.2/installation.html#quick-setup and read that its quick setup was not compatible with gzipmiddleware. I remembered that I had seen gzip in the template referring to whitenoise. When I clicked on the link provided on the debug install page, I got this ominous warning from Django: https://docs.djangoproject.com/en/1.7/ref/middleware/#module-django.middleware.gzip.

Any clarification / explanation appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.