在Django夹层项目启动期间,我收到以下消息:
You have 7 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): auth, blog, conf, forms, galleries, mainapp, pages.
Run 'python manage.py migrate' to apply them.
我还没有真正注意到它何时/为什么开始出现。我绝对没有更新任何库。
迁移时,只要访问任何页面,都会出现以下错误:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.11
Python Version: 3.6.5
Installed Applications:
('mezzanine.boot',
'modeltranslation',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.redirects',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'mezzanine.conf',
'mezzanine.core',
'mezzanine.generic',
'mezzanine.pages',
'mezzanine.blog',
'mezzanine.forms',
'mezzanine.galleries',
'mezzanine.twitter',
'mainapp',
'filebrowser_safe',
'grappelli_safe',
'django.contrib.admin',
'django.contrib.staticfiles',
'django_comments')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'mezzanine.core.request.CurrentRequestMiddleware',
'mezzanine.core.middleware.RedirectFallbackMiddleware',
'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
'mezzanine.core.middleware.SitePermissionMiddleware',
'mezzanine.pages.middleware.PageMiddleware')
Template error:
In template /home/matous/PycharmProjects/webapps/iacah/app/templates/base.html, error at line 0
__str__ returned non-string (type NoneType) 1 : <!doctype html>
2 : <html lang="{{ LANGUAGE_CODE }}"{% if LANGUAGE_BIDI %} dir="rtl"{% endif %}>
3 : {% load pages_tags mezzanine_tags i18n staticfiles %}
4 :
5 : <head>
6 : <meta http-equiv="Content-type" content="text/html; charset=utf-8">
7 : <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 : <meta name="keywords" content="{% block meta_keywords %}{% endblock %}">
9 : <meta name="description" content="{% block meta_description %}{% endblock %}">
10 : <title>{% block meta_title %}{% endblock %}{% if settings.SITE_TITLE %} | {{ settings.SITE_TITLE }}{% endif %}</title>
Traceback:
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py" in _get_response
178. response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/matous/.local/lib/python3.6/site-packages/mezzanine/pages/middleware.py" in process_view
90. return view_func(request, *view_args, **view_kwargs)
File "/home/matous/PycharmProjects/webapps/iacah/app/mainapp/views.py" in home
36. "news": news
File "/usr/local/lib/python3.6/dist-packages/django/shortcuts.py" in render
30. content = loader.render_to_string(template_name, context, request, using=using)
File "/usr/local/lib/python3.6/dist-packages/django/template/loader.py" in render_to_string
68. return template.render(context, request)
File "/usr/local/lib/python3.6/dist-packages/django/template/backends/django.py" in render
66. return self.template.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render
207. return self._render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/loader_tags.py" in render
177. return compiled_parent._render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/loader_tags.py" in render
72. result = block.nodelist.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in render
1040. output = self.filter_expression.resolve(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in resolve
708. obj = self.var.resolve(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in resolve
849. value = self._resolve_lookup(context)
File "/usr/local/lib/python3.6/dist-packages/django/template/base.py" in _resolve_lookup
911. current = current()
File "/home/matous/.local/lib/python3.6/site-packages/mezzanine/core/models.py" in meta_title
162. return self._meta_title or getattr(self, "title", str(self))
Exception Type: TypeError at /
Exception Value: __str__ returned non-string (type NoneType)
在迁移之前,一切正常。我使用:
如果我在迁移后访问管理页面,则所有页面的标题均为空白(不显示标题,因此无法对其进行编辑或删除。