Django在setting.py中找不到已安装的应用程序

时间:2019-05-25 16:43:44

标签: django python-3.x

我正在尝试使用python / django创建一个Web应用程序,但是该应用程序发生了一个应用程序错误,并且它们在setting.py中没有明确显示

由于我的例行工作,我使用两台计算机进行开发,其中一台发生错误,而另一台则没有。我在google上进行了很好的搜索,但是所有解决方案都没有效果,令我更沮丧的是,该代码可以在一台计算机上运行而另一台计算机无法运行。

setting.py

INSTALLED_APPS = [
    'django.contrib.staticfiles',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'simple_history',
    'blog.apps.BlogConfig',
    'users.apps.UsersConfig',
    'django.contrib.admin',
    'django.contrib.sessions',
    'django.contrib.messages',
    'crispy_forms',
    'storages'
    ]

*Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "C:\ProgramData\Anaconda3\lib\site-



 packages\django\core\management\__init__.py", line 381, in execute_from_command_line
        utility.execute()
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 375, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
        self.execute(*args, **cmd_options)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
        super().execute(*args, **options)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 364, in execute
        output = self.handle(*args, **options)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
        self.run(**options)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
        autoreload.run_with_reloader(self.inner_run, **options)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
        start_django(reloader, main_func, *args, **kwargs)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
        reloader.run(django_main_thread)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 272, in run
        get_resolver().urlconf_module
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\functional.py", line 80, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
        return import_module(self.urlconf_name)
      File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\Users\Rafael\Google Drive\Python\Django\django_project\django_project\urls.py", line 17, in <module>
        from django.contrib.auth import views as auth_views
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\auth\views.py", line 10, in <module>
        from django.contrib.auth.forms import (
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\auth\forms.py", line 10, in <module>
        from django.contrib.auth.models import User
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
        from django.contrib.contenttypes.models import ContentType
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\contrib\contenttypes\models.py", line 133, in <module>
        class ContentType(models.Model):
      File "C:\ProgramData\Anaconda3\lib\site-packages\django\db\models\base.py", line 111, in __new__
        "INSTALLED_APPS." % (module, name)

RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.*

0 个答案:

没有答案