RobertDjangostudent
RobertDjangostudent

Reputation: 199

Every time I run Python manage.py I get this error

pycharm@glenn-liveconsole3:~/mysite/quickstart$ django-admin.py syncdb
Traceback (most recent call last):
  File "/home/pycharm/.virtualenvs/anchondo/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command
_line
    utility.execute()
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/pycharm/.virtualenvs/anchondo/local/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment va
riable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

All I am doing is running python manage.py syncdb or python manage.py migrate I am trying to update the website the models created a new model an am trying to migrate the info website works but I can not do syncdb in the console

Upvotes: -1

Views: 986

Answers (1)

Klaus D.
Klaus D.

Reputation: 14404

When you create your project with django-admin startproject a manage.py will be generated that has a line like:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")

where my_project is your project name. This points to your settings file. Make sure the line exists and point to the right settings module.

Also use manage.py instead of django-admin to manage an existing project.

Upvotes: 0

Related Questions