简体   繁体   中英

Django admin tool broken?

I've installed django on OS X 10.9.5 using pip, and everything worked great for a day. I fired it up the next day and the tool seems to be broken.

Now, any command I issue aside from "startproject" fails with the following output. I've tried starting a totally clean project, and I get the same thing.

$ django-admin manage.py check
Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 11, in <module>
    sys.exit(execute_from_command_line())
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 182, in fetch_command
    settings.INSTALLED_APPS
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Not sure how helpful it is, since this is a fresh project, but here's the output from manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testdjango.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

I've tried uninstall/reinstalling django. Where should I look next?

Your syntax is incorrect. You should either type

django-admin check

or

python manage.py check

That being said; django-admin is only useful when creating the project. You should use the manage.py script for project-specific tasks. From the docs :

Generally, when working on a single Django project, it's easier to use manage.py than django-admin. If you need to switch between multiple Django settings files, use django-admin with DJANGO_SETTINGS_MODULE or the --settings command line option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM