Coder Social home page Coder Social logo

heroku / django-heroku Goto Github PK

View Code? Open in Web Editor NEW
459.0 93.0 141.0 42 KB

[DEPRECATED] Do not use! See https://github.com/heroku/django-heroku/issues/56

License: BSD 3-Clause "New" or "Revised" License

Python 99.35% Makefile 0.34% Procfile 0.32%

django-heroku's Introduction

Django-Heroku (Python Library)

https://travis-ci.org/heroku/django-heroku.svg?branch=master

This is a Django library for Heroku applications that ensures a seamless deployment and development experience.

This library provides:

  • Settings configuration (Static files / WhiteNoise).
  • Logging configuration.
  • Test runner (important for Heroku CI).

Django 2.0 is targeted, but older versions of Django should be compatible. Only Python 3 is supported.

Usage of Django-Heroku

In settings.py, at the very bottom:

โ€ฆ
# Configure Django App for Heroku.
import django_heroku
django_heroku.settings(locals())

This will automatically configure DATABASE_URL, ALLOWED_HOSTS, WhiteNoise (for static assets), Logging, and Heroku CI for your application.

Bonus points! If you set the SECRET_KEY environment variable, it will automatically be used in your Django settings, too!

Disabling Functionality

settings() also accepts keyword arguments that can be passed False as a value, which will disable automatic configuration for their specific areas of responsibility:

  • databases
  • test_runner
  • staticfiles
  • allowed_hosts
  • logging
  • secret_key

You can also just use this library to provide a test runner for your Django application, for use on Heroku CI:

import django_heroku
TEST_RUNNER = 'django_heroku.HerokuDiscoverRunner'

django-heroku's People

Contributors

danidee10 avatar jmorrell avatar kennethreitz avatar p13i avatar sigmavirus24 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

django-heroku's Issues

Add Settings Configuration for DEBUG

NEW FEATURE REQUEST

The settings function reads in config vars like SECRET_KEY and DATABASE_URL. It would be really helpful if it could also read DEBUG as a config var. That way, DEBUG could be "True" in the local .env file or in development environments, while it could be "False" in staging and production environments. It makes sense to control this value as a config var, rather than hard-coding it in the settings.py file. (Of course, there should also be documentation strongly advising programmers not to set DEBUG=True in production.)

Deployment check warnings

After deploying, running python manage.py check --deploy produces the following warnings:

?: (security.W004) You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.
?: (security.W006) Your SECURE_CONTENT_TYPE_NOSNIFF setting is not set to True, so your pages will not be served with an 'X-Content-Type-Options: nosniff' header. You should consider enabling this header to prevent the browser from identifying content types incorrectly.
?: (security.W007) Your SECURE_BROWSER_XSS_FILTER setting is not set to True, so your pages will not be served with an 'X-XSS-Protection: 1; mode=block' header. You should consider enabling this header to activate the browser's XSS filtering and help prevent XSS attacks.
?: (security.W008) Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.
?: (security.W012) SESSION_COOKIE_SECURE is not set to True. Using a secure-only session cookie makes it more difficult for network traffic sniffers to hijack user sessions.
?: (security.W016) You have 'django.middleware.csrf.CsrfViewMiddleware' in your MIDDLEWARE, but you have not set CSRF_COOKIE_SECURE to True. Using a secure-only CSRF cookie makes it more difficult for network traffic sniffers to steal the CSRF token.
?: (security.W019) You have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE, but X_FRAME_OPTIONS is not set to 'DENY'. The default is 'SAMEORIGIN', but unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.

ALLOWED_HOSTS Security

Hello,

First, I am not an expert in Django or with Heroku use. I have used both on a number of projects, though. I am concerned that django-heroku sets the ALLOWED_HOSTS setting to '*'. In the django docs, this is not secure due to the possibility of host header attacks. This is explained in two places-

Host Headers Virtual Hosting
allowed hosts

I understand that this setting can be overwridden with allowed_hosts=False but out of the box I think it should avoid introducing any security flaws. Perhaps this is a non-issue, in which case I would love to understand the Heroku service more. To remedy this, I would be interested to know if Heroku provides any information about the url that can be levereged (like an environment variable). I will do some research on my own but I would be interested to see what the authors here have to say.

STATIC_ROOT warning despite using this library

I am pretty new to heroku and django but I have been following these instructions https://devcenter.heroku.com/articles/django-app-configuration

I can succesfully run my application locally, but when trying to push the app to heroku I get:

File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 43, in path raise ImproperlyConfigured("You're using the staticfiles app " django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

As far as I can tell from looking at your code this is exactly what django-heroku should be doing for me, I've tried adding the STATIC_ROOT but it makes no difference. As far as I can tell there isn't any significant difference between my skeleton application and the getting-started project https://github.com/heroku/python-getting-started which uses django-heroku and doesn't set the STATIC_ROOT either. I've compared the settings and they seem much the same.

Here's my code https://github.com/theodi/dataset-summaries-web

What am I doing wrong?

SyntaxError in django_heroku

on i try run server

Traceback (most recent call last):
File "./manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/dell/.local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/home/dell/.local/lib/python2.7/site-packages/django/core/management/init.py", line 308, in execute
settings.INSTALLED_APPS
File "/home/dell/.local/lib/python2.7/site-packages/django/conf/init.py", line 56, in getattr
self._setup(name)
File "/home/dell/.local/lib/python2.7/site-packages/django/conf/init.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/dell/.local/lib/python2.7/site-packages/django/conf/init.py", line 110, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/dell/Workshop/ArNews/python-getting-started/gettingstarted/settings.py", line 14, in
import django_heroku
File "/usr/local/lib/python2.7/dist-packages/django_heroku/init.py", line 1, in
from .core import *
File "/usr/local/lib/python2.7/dist-packages/django_heroku/core.py", line 45
def settings(config, *, db_colors=False, databases=True, test_runner=True, staticfiles=True, allowed_hosts=True, logging=True, secret_key=True):
^
SyntaxError: invalid syntax

i use python ver : 2.7.14

When my tests end, I get this error: syntax error at or near "("

When my tests end, I get this error: syntax error at or near "(":

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: syntax error at or near "("
LINE 2:                     DROP TABLE (
                                       ^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "manage.py", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
    super().run_from_argv(argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 56, in handle
    failures = test_runner.run_tests(test_labels)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/test/runner.py", line 607, in run_tests
    self.teardown_databases(old_config)
  File "/app/.heroku/src/django-heroku/django_heroku/core.py", line 45, in teardown_databases
    self._wipe_tables(connection)
  File "/app/.heroku/src/django-heroku/django_heroku/core.py", line 38, in _wipe_tables
    """
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: syntax error at or near "("
LINE 2:                     DROP TABLE (
                                       ^

Fix Psycopg2 warning

Using this module, I get a warning on startup:

lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)

This warning can be easily fixed by changing the dependency to psycopg2-binary instead of psycopg2.

Another issue is using pipenv graph, I see the following dependencies which looks different from what I see in the Pipenv file for this project:

django-heroku==0.2.0
  - dj-database-url [required: Any, installed: 0.4.2]
  - django [required: Any, installed: 2.0.2]
    - pytz [required: Any, installed: 2018.3]
  - psycopg2 [required: Any, installed: 2.7.4]
  - whitenoise [required: Any, installed: 3.3.1]

In the Pipenv file, I don't see psycopg2 but I do see gunicorn which is not present above.

Unable to install django-heroku on mac osx Mojave

When I try to install django-heroku in my project I have this error:

An error occurred while installing psycopg2==2.8.3 --hash=sha256:128d0fa910ada0157bba1cb74a9c5f92bb8a1dca77cf91a31eb274d1f889e001 --hash=sha256:227fd46cf9b7255f07687e5bde454d7d67ae39ca77e170097cdef8ebfc30c323 --hash=sha256:2315e7f104681d498ccf6fd70b0dba5bce65d60ac92171492bfe228e21dcc242 --hash=sha256:4b5417dcd2999db0f5a891d54717cfaee33acc64f4772c4bc574d4ff95ed9d80 --hash=sha256:640113ddc943522aaf71294e3f2d24013b0edd659b7820621492c9ebd3a2fb0b --hash=sha256:897a6e838319b4bf648a574afb6cabcb17d0488f8c7195100d48d872419f4457 --hash=sha256:8dceca81409898c870e011c71179454962dec152a1a6b86a347f4be74b16d864 --hash=sha256:b1b8e41da09a0c3ef0b3d4bb72da0dde2abebe583c1e8462973233fd5ad0235f --hash=sha256:cb407fccc12fc29dc331f2b934913405fa49b9b75af4f3a72d0f50f57ad2ca23 --hash=sha256:d3a27550a8185e53b244ad7e79e307594b92fede8617d80200a8cce1fba2c60f --hash=sha256:f0e6b697a975d9d3ccd04135316c947dd82d841067c7800ccf622a8717e98df1! Will try again.

I'm using pipenv, I tried to install psycopg locally using brew and also I tried with two different macs but I can't make it work.

pg_config executable not found.

When trying to pip install django-heroku, I get an error:

pg_config executable not found.

Perhaps this project could be updated to use psycopg2-binary as a dependency?

cannot install because of psycopg2 requirement

I cannot install django-heroku because of psycopg2 requirement. But psycopg2-binary is already installed..

(env) p3ngu1ns-MacBook-Pro:bin p3ngu1n$ ./python pip install psycopg2-binary
Requirement already satisfied: psycopg2-binary in /Users/p3ngu1n/Documents/Develop/python/tutorials/producthuntclone/env/lib/python3.7/site-packages (2.8.3)
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

(env) p3ngu1ns-MacBook-Pro:bin p3ngu1n$ ./python pip install django-heroku
Collecting django-heroku
  Using cached https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
Collecting psycopg2 (from django-heroku)
  Using cached https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
    
    Error: pg_config executable not found.
    
    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    
    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.
    
    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).
    
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/lh/t8sygs3s7ld19xncfzlymtb40000gn/T/pip-install-xngbqf6n/psycopg2/
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Infinite structure

This line:

config['DATABASES']['default']['TEST'] = config['DATABASES']['default']

should probably be:

config['DATABASES']['default']['TEST'] = config['DATABASES']['default'].copy()

to avoid generating an infinite structure that generates an infinite loop in django/views/debug.py line 58,

Heroku CI does not work with in-dyno databases

When running Heroku CI with in-dyno Postgres database, I got a django.db.utils.ProgrammingError: role "postgres" does not exist error.

Here is my app.json

{
  "buildpacks": [
    {
      "url": "heroku/python"
    }
  ],
  "environments": {
    "test": {
      "formation": {
        "test": {
          "quantity": 1,
          "size": "performance-m"
        }
      },
      "scripts": {
        "test": "flake8 fugoproj && python fugoproj/manage.py test fugoproj"
      },
      "addons": [
        "heroku-postgresql:in-dyno"
      ]
    }
  }
}

Here is the heroku test setup log (succeed)

-----> Fetching https://github.com/heroku/heroku-buildpack-ci-postgresql buildpack...
       buildpack downloaded
-----> Fetching heroku/python buildpack...
       buildpack downloaded
-----> postgresql app detected
       Using postgresql version: 10.1
       Using stack version: heroku-16
-----> Fetching and vendoring postgresql into slug
-----> Initializing database
       The files belonging to this database system will be owned by user "u36536".
       This user must also own the server process.
       
       The database cluster will be initialized with locale "en_US.UTF-8".
       The default text search configuration will be set to "english".
       
       Data page checksums are disabled.
       
       creating directory /app/vendor/postgresql/data ... ok
       creating subdirectories ... ok
       selecting default max_connections ... 100
       selecting default shared_buffers ... 128MB
       selecting dynamic shared memory implementation ... posix
       creating configuration files ... ok
       running bootstrap script ... ok
       performing post-bootstrap initialization ... ok
       syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
       
       Success. You can now start the database server using:
       
           pg_ctl -D /app/vendor/postgresql/data -l logfile start
       
       waiting for server to start.... done
       server started
       CREATE ROLE
-----> Copying .profile.d/pg.sh to add postgresql binaries to PATH
-----> postgresql done
-----> Python app detected
       Skipping installation, as Pipfile.lock hasn't changed since last deploy.
-----> No test-setup command provided. Skipping.

Here is the heroku test log (fails)

-----> Running test command `flake8 fugoproj && python fugoproj/manage.py test fugoproj`...
/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Using existing test database for alias 'default'...
System check identified no issues (0 silenced).
..........................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 314 tests in 50.910s
OK
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: role "postgres" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "fugoproj/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 62, in handle
    failures = test_runner.run_tests(test_labels)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/test/runner.py", line 604, in run_tests
    self.teardown_databases(old_config)
  File "/app/.heroku/python/lib/python3.6/site-packages/django_heroku/core.py", line 41, in teardown_databases
    self._wipe_tables(connection)
  File "/app/.heroku/python/lib/python3.6/site-packages/django_heroku/core.py", line 33, in _wipe_tables
    """
  File "/app/.heroku/python/lib/python3.6/site-packages/raven/contrib/django/client.py", line 127, in execute
    return real_execute(self, sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: role "postgres" does not exist
-----> test command `flake8 fugoproj && python fugoproj/manage.py test fugoproj` failed with exit status 1

Additional note

  • I'm configuring DATABASE with ssl_require=False, otherwise it does not work at all.

Errors after test run

When I run ./manage.py test on GitLab CI I get the following error.

After test output:

Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/utils.py", line 83, in _execute
    return self.cursor.execute(sql)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 294, in execute
    return Database.Cursor.execute(self, query)
sqlite3.OperationalError: near "SCHEMA": syntax error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
    super().run_from_argv(argv)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/core/management/commands/test.py", line 56, in handle
    failures = test_runner.run_tests(test_labels)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/test/runner.py", line 607, in run_tests
    self.teardown_databases(old_config)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django_heroku/core.py", line 41, in teardown_databases
    self._wipe_tables(connection)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django_heroku/core.py", line 33, in _wipe_tables
    """
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/utils.py", line 83, in _execute
    return self.cursor.execute(sql)
  File "/root/.local/share/virtualenvs/project-xauW7Ao3/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 294, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: near "SCHEMA": syntax error

Work around is to call settings only on heroku:

if 'HEROKU' in os.environ:
    import django_heroku
    django_heroku.settings(locals())

Might be related to #31 but the traceback differs a lot.

Application error

heruko log

2018-09-22T10:50:25.744954+00:00 app[api]: Enable Logplex by user [email protected]
2018-09-22T10:50:25.662907+00:00 app[api]: Release v1 created by user [email protected]
2018-09-22T10:50:25.744954+00:00 app[api]: Release v2 created by user [email protected]
2018-09-22T10:50:25.662907+00:00 app[api]: Initial release by user [email protected]
2018-09-22T10:55:31.540366+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=6a75a895-9e46-48a0-8f45-e61d903509da fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-22T10:55:31.990721+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=carental.herokuapp.com request_id=ec92e2d8-fff8-44d4-96d2-00e3142ab379 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T15:31:18.864556+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=2b17bcf2-890e-4845-ad6d-5c1e683573b8 fwd="92.242.59.6" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T15:31:19.036137+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=carental.herokuapp.com request_id=517f7c8e-f0cd-4c6c-9088-5d6a9fba8e5d fwd="92.242.59.6" dyno= connect= service= status=502 bytes= protocol=http
2018-09-24T15:31:19.525837+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=carental.herokuapp.com request_id=d2a65d75-5afb-47cf-bb87-492e629c703b fwd="92.242.59.6" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T16:50:28.000000+00:00 app[api]: Build started by user [email protected]
2018-09-24T16:50:29.000000+00:00 app[api]: Build failed -- check your build logs
2018-09-24T17:10:54.000000+00:00 app[api]: Build started by user [email protected]
2018-09-24T17:10:55.000000+00:00 app[api]: Build failed -- check your build logs
2018-09-24T17:12:12.000000+00:00 app[api]: Build started by user [email protected]
2018-09-24T17:12:13.000000+00:00 app[api]: Build failed -- check your build logs
2018-09-24T23:19:01.222619+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=112e7a07-00e1-480a-bd1d-78b7552dd422 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:29:21.790175+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=3ce54aa7-9365-4160-a16a-fe46c4e74f2c fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:31:35.313650+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=41fe5365-cc32-4ee3-874d-8a003e639e69 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:31:39.032214+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=849c42ae-8740-4539-b2bb-cdf5bf5a8a10 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:32:11.438325+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=007863eb-794c-46d6-b7e7-105988661e25 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:37:26.014499+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=carental.herokuapp.com request_id=9cdfcc0d-204b-4040-969d-a7ad4fc7f2b7 fwd="195.9.254.2" dyno= connect= service= status=502 bytes= protocol=https
2018-09-24T23:42:53.000000+00:00 app[api]: Build started by user [email protected]
2018-09-24T23:43:26.695726+00:00 app[api]: Release v3 created by user [email protected]
2018-09-24T23:43:26.695726+00:00 app[api]: Attach DATABASE (@ref:postgresql-curved-19568) by user [email protected]
2018-09-24T23:43:27.223334+00:00 app[api]: Release v4 created by user [email protected]
2018-09-24T23:43:27.223334+00:00 app[api]: Deploy a609ea4e by user [email protected]
2018-09-24T23:43:36.000000+00:00 app[api]: Build succeeded
2018-09-24T23:43:46.880870+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=7fbb166b-085e-4ff8-8cec-8785dabb60ad fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:43:50.578661+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=cdaaa284-8c29-4989-ad44-74f6534cb83c fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:43:53.141433+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=10ca2f5f-7621-4017-b1b2-33f1fa71c105 fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:44:50.540397+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=9bb85413-afd2-4238-81a9-59bc430eaf32 fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:45:14.607445+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=7c09f71b-b54e-461c-92d0-125a96be3c9f fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:52:30.252877+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=92b59d49-0fb3-4bf5-b1a3-0f9d4c2bbd41 fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https
2018-09-24T23:56:25.122766+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=carental.herokuapp.com request_id=85677a93-a2f1-4b57-95c5-e4c405b2b844 fwd="195.9.254.2" dyno= connect= service= status=503 bytes= protocol=https

This project is sunset

The decision has been made to deprecate + sunset this project, since:

  • Configuring Django for Heroku does not actually require many changes (eg reading DATABASES_URL and setting up WhiteNoise - which already has great docs), so does not really need a complex helper package to achieve this.
  • Hiding settings in a package makes it harder for users to understand what is actually happening, hindering debugging, and making it more confusing when wanting to override parts of django-heroku but not others. And IMO it's against Python's "explicit is better than implicit" mentality.
  • Having the config as a package brings with it a bunch of maintenance/compatibility concerns. For example, does this package have to support multiple versions of Django, or do we only support latest, and then have to make sure users check a support matrix of compatible versions first? Or, how do users use a brand new (or even beta) version of Django, until we've had time to update the package?

To migrate away from django-heroku, inline the config it used to set in your settings.py.

An example of doing that can be seen here, in the commit that migrated Heroku's Getting Started on Python guide away from the package:
heroku/python-getting-started@14230b2

If you happened to use one of the opt-in/more advanced django-heroku features such as db_colors=True, then inline those parts of the config as needed. You can find django-heroku's original full config here:
https://github.com/heroku/django-heroku/blob/v0.3.0/django_heroku/core.py

(Note: The latest version of django-heroku on the master branch is actually slightly broken, and doesn't match the published release on PyPI. To see what's on PyPI, make sure to view on GitHub via the v0.3.0 Git tag - as the link above does.)

Do not replace `config['DATABASES']['default']`, do deep update or simple update or `dict(config['DATABASES']['default'], **dj_database_url.config(conn_max_age=MAX_CONN_AGE, ssl_require=True))` instead

Do not replace config['DATABASES']['default'], do deep update or simple update or dict(config['DATABASES']['default'], **dj_database_url.config(conn_max_age=MAX_CONN_AGE, ssl_require=True)) instead.

The way it is implemented now sweeps out my ATOMIC_REQUESTS and other settings. Fixing this would also solve: #11

Permit disabling 'require_ssl' when running locally for development

When using this module, I would like the ability to set ssl_require to False for the database connection in a scenario where the Postgres instance defined in DATABASE_URL is NOT hosted at Heroku.

Let me explain:
During local development, I use a Postgres database on Localhost rather than my production Heroku Postgres instance. Requiring SSL complicates the local dev environment.

I'm not asking for any change to behavior when connecting to Heroku-hosted Postgres.

Uses wrong database when GeoDjango is in use

If BUILD_WITH_GEO_LIBRARIES is set, the wrong database engine is used.

My work-around is:

django_heroku.settings(locals())

if DATABASES['default']['ENGINE'] in ('django.db.backends.postgresql', 'django.db.backends.postgresql_psycopg2'):
    DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'
elif DATABASES['default']['ENGINE'] == 'django.db.backends.sqlite3':
    DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.spatialite'

Is this project being maintained?

Looks like this is mostly the work of @kennethreitz (THANK YOU!) and of course owned by the Heroku account, but little maintainer activity in the past 7 months. Is it being maintained or should we stop using it?

BASE_DIR setting not found

Seems like this project has an implicit dependency on BASE_DIR being defined in settings.py.
While this is the case in the default project created by django-admin, it doesn't appear, for example, in the popular django cookie-cutter project.

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.