将应用程序添加到Django

时间:2012-07-21 16:39:32

标签: python django

我尝试将应用程序添加到Django并命名为app main。我输入了django-admin.py startapp main。

当我运行python manage.py runserver时,我遇到了这个错误:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 459, in execute_manager
    utility.execute()
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/cnnlakshmen_2000/Projects/env/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 "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in <module>
    from django.db import models
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'main.settings' (Is it on sys.path?): No module named settings

不确定如何解决错误...需要一些指导...

1 个答案:

答案 0 :(得分:5)

不要给应用程序提供与项目相同的名称; Django将难以区分它们。