Open brodul opened 5 years ago
if 'HEROKU' in os.environ:
import django_heroku
django_heroku.settings(locals())
No longer work. To find out why, run this command.
heroku run python3
python3
>>>import os
>>>os.environ
Will find out.
Now, I use this code
import os
if '/app' in os.environ['HOME']:
import django_heroku
django_heroku.settings(locals())
To avoid error. If you have a better way, please let me know.
Having the same problem on Travis CI.
Near identical traceback:
Traceback (most recent call last):
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, 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 "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
super().run_from_argv(argv)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/commands/test.py", line 56, in handle
failures = test_runner.run_tests(test_labels)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/test/runner.py", line 607, in run_tests
self.teardown_databases(old_config)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django_heroku/core.py", line 41, in teardown_databases
self._wipe_tables(connection)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django_heroku/core.py", line 33, in _wipe_tables
"""
File "/home/travis/virtualenv/python3.6.3/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 "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: near "SCHEMA": syntax error
The command "python manage.py test" exited with 1.
@wwin3286tw 's suggestion worked, and build now passes
Same issue confirmed. I've approached this slightly different. I am new with Heroku so I might misunderstand something, but I think this is cleaner since it gives me more control over the environment variable I'll be looking for. Credit.
$ heroku config:set I_AM_HEROKU=yes -a APP
if 'I_AM_HEROKU' in os.environ:
# Configure Django App for Heroku.
import django_heroku
django_heroku.settings(locals())
I had the same issue, but with Travis CI. The problem was that for some reason the commits to the default sqlite database didn't work, so setting a postgresql database solved it for me
When I run
./manage.py test
on GitLab CI I get the following error.After test output:
Work around is to call
settings
only on heroku:Might be related to #31 but the traceback differs a lot.