2017-07-25 93 views
0

我正在創建一個django應用程序,我最近安裝了django tinymce。我將該應用添加到了我的settings.py中。但是,當我嘗試遷移,我得到這個錯誤:Django運行時錯誤

Unhandled exception in thread started by <function wrapper at 0x7fec01852d70> 
Traceback (most recent call last): 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
    fn(*args, **kwargs) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run 
    self.check(display_num_errors=True) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/management/base.py", line 374, in check 
    include_deployment_checks=include_deployment_checks, 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/management/base.py", line 361, in _run_checks 
    return checks.run_checks(**kwargs) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks 
    new_errors = check(app_configs=app_configs) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/checks/urls.py", line 14, in check_url_config 
    return check_resolver(resolver) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/core/checks/urls.py", line 24, in check_resolver 
    for pattern in resolver.url_patterns: 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/urls/resolvers.py", line 313, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ 
    res = instance.__dict__[self.name] = self.func(instance) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/urls/resolvers.py", line 306, in urlconf_module 
    return import_module(self.urlconf_name) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/home/agozie/kingdom-ambassadors/kingdom/urls.py", line 23, in <module> 
    url(r'^', include('blog.urls')), 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include 
    urlconf_module = import_module(urlconf_module) 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/home/agozie/kingdom-ambassadors/blog/urls.py", line 2, in <module> 
    from blog import views 
    File "/home/agozie/kingdom-ambassadors/blog/views.py", line 8, in <module> 
    from .forms import RegisterForm, LoginForm, CommentForm 
    File "/home/agozie/kingdom-ambassadors/blog/forms.py", line 7, in <module> 
    from django.contrib.flatpages.models import FlatPage 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/contrib/flatpages/models.py", line 11, in <module> 
    class FlatPage(models.Model): 
    File "/home/agozie/anaconda2/envs/my_env/lib/python2.7/site-packages/django/db/models/base.py", line 113, in __new__ 
    "INSTALLED_APPS." % (module, name) 
RuntimeError: Model class django.contrib.flatpages.models.FlatPage doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. 

這裏是我的settings.py:

INSTALLED_APPS = [ 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'django.contrib.sites', 
    'blog', 
    'tinymce', 
] 

SITE_ID = 1 

我該如何解決這個問題?在此先感謝

回答

0

As instructed,必須

Add 'django.contrib.flatpages' to your INSTALLED_APPS setting.

另外,還要確保你要麼使用FlatpageFallbackMiddleware,或者你已經有了正確配置您的網址(見前面的鏈接)。