Django app: Run button gives error, but running server from console is fine

django
python

#1

I am running a Django app that I have been working with from the original C9 setup. When I type into the console “python manage.py runserver $IP:$PORT”, my app works well at the link https://app_name-username.c9users.io. However, when I click the ‘Run’ button, I get the below error. I would like the Run button to work just like the console command. Please help!

Traceback (most recent call last):
File “manage.py”, line 10, in
execute_from_command_line(sys.argv)
File “/usr/local/lib/python2.7/dist-packages/django/core/management/init.py”, line 350, in execute_from_command_line
utility.execute()
File “/usr/local/lib/python2.7/dist-packages/django/core/management/init.py”, line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/usr/local/lib/python2.7/dist-packages/django/core/management/base.py”, line 348, in run_from_argv
self.execute(*args, **cmd_options)
File “/usr/local/lib/python2.7/dist-packages/django/core/management/base.py”, line 399, in execute
output = self.handle(*args, **options)
File “/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py”, line 89, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File “/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py”, line 20, in init
self.loader = MigrationLoader(self.connection)
File “/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py”, line 49, in init
self.build_graph()
File “/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py”, line 176, in build_graph
self.applied_migrations = recorder.applied_migrations()
File “/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py”, line 65, in applied_migrations
self.ensure_schema()
File “/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py”, line 52, in ensure_schema
File “/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py”, line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File “/usr/local/lib/python2.7/dist-packages/django/db/backends/dummy/base.py”, line 21, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.


Django server not displaying app
#2

There are several possible issues:

  • run button calls python manage.py migrate before runserver https://github.com/c9/core/blob/master/plugins/c9.ide.run/runners-docker/Django.run#L7, maybe the error happens when doing migrate?
  • maybe you have modified .bashrc or other similar file, and environments for interactive and noninteractive terminals are different, so version invoked with run button misses some variables.
  • do you use same python executable in both cases, or do you use virtualenv or something similar?

#3

Yes you are right that

python manage.py migrate

throws the error that I pasted in my original question. I am using MongoDB, so I don’t need to migrate. I am not sure why this just recently started happening, as I was using the Run button just fine earlier. Seems to coincide with when I was messing with settings for my first Heroku deployment.

I am not using a virtualenv. I am using the default Cloud9 environment.

The DATABASES section of my settings.py looks like this:

DATABASES = {
default’: {
ENGINE’: ‘django.db.backends.dummy’
}
}


#4

you can edit the runner and remove the migrate part.