heroku / heroku-django-template Goto Github PK
View Code? Open in Web Editor NEWA Django 2.0 base template featuring all recommended best practices for deployment on Heroku and local development.
Home Page: https://www.heroku.com/python
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
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)
Wrapping the WSGI application with DjangoWhiteNoise
seems to have been replaced by adding WhiteNoiseMiddleware
.
Looking at the template, the new middleware has been added but the wrapping is still being done:
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!๐ณ
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?
Is there a reason why 'whitenoise.middleware.WhiteNoiseMiddleware', is ot included in MIDDLEWARE in 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
Might be worth considering adding a sample LOGGING
config to show exceptions in the Heroku logs?
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.
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.
This template should explain how to use it in Python 3 (namely, by modifying the runtime.txt
file).
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?
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.
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!
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.
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
.
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.
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
.
When I run python manage.py startapp appname
, the TypeError in the subject of this issue is thrown.
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. :)
You might want to change the description of the repository from Django 1.11
to Django 2.0
.
Although the ReadMe and the commits say Django 1.11, the Description
still has 1.10 in it.
Hi folks:
I found an outdated link:
I'll have a PR up in a few minutes.
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'
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.
The project description should say Django 1.10 as it does in the README.md.
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
For more ultimate power: https://github.com/audreyr/cookiecutter
๐
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:
Once it's available on the command-line.
Is there anything different about the setup from 1.9 to 1.10?
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
When the django project is in the same directory as a virtualenv folder then the git pish heroku master fails.
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
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.
This project is an awesome starter for the heroku
-based apps. Thanks!
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
.
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.
Pros:
Cons:
Maybe I am missing any cons, please correct me if I am wrong.
Here's a detailed article I wrote on this topic: https://medium.com/wemake-services/managing-djangos-settings-e2b7f496120d
So, what do you think?
Looks like dj_database_url
was not defined as a requirement.
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?
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).
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.
I get the following warning with the template.
WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG.
It's nothing serious, and can be easily solved with this
https://stackoverflow.com/questions/32445953/django-app-works-fine-but-getting-a-template-warning-message
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
Why did you redefine BASE_DIR for static files? https://github.com/rougeth/heroku-django-template/blob/master/project_name/settings.py#L93 I didn't get the difference.
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.
With the current requirements.txt, I get an error when running pip install -r requirements.txt
, like this:
psycopg/psycopg2#594
I fix it by removing the version in requirements.txt, and now I can install psycopg and connect postgres.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.