内容类型错误

时间:2015-09-01 12:36:12

标签: django

我正在使用Django 1.8,我有一个应用程序运行完全正常。但现在我迁移了整个数据库,每当我尝试访问管理员中的记录时,我都会收到此错误:

Internal Server Error: /admin/mitglieder/mitglied/22/
Traceback (most recent call last):
  File "/home/franzritt/django-club41/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 583, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/home/franzritt/django-club41/django/utils/decorators.py", line 105, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/franzritt/django-club41/django/views/decorators/cache.py", line 52, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/franzritt/django-club41/django/contrib/admin/sites.py", line 206, in inner
    return view(request, *args, **kwargs)
  File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1456, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/home/franzritt/django-club41/django/utils/decorators.py", line 29, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/franzritt/django-club41/django/utils/decorators.py", line 105, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/franzritt/django-club41/django/utils/decorators.py", line 25, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/franzritt/django-club41/django/db/transaction.py", line 394, in inner
    return func(*args, **kwargs)
  File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1450, in changeform_view
    return self.render_change_form(request, context, add=add, change=not add, obj=obj, form_url=form_url)
  File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1088, in render_change_form
    'content_type_id': get_content_type_for_model(self.model).pk,
  File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 63, in get_content_type_for_model
    return ContentType.objects.get_for_model(obj, for_concrete_model=False)
  File "/home/franzritt/django-club41/django/contrib/contenttypes/models.py", line 58, in get_for_model
    " is migrated before trying to migrate apps individually."
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

我用1.7开始了这个项目,但我已经转移到1.8并且一个应用程序运行没有问题。但是,我以前没有迁移过整个项目。我从迁移历史记录中看到的是,此迁移在auth应用程序上进行了迁移。但即使我在此之前迁移回来,我也会遇到同样的错误。

切换到1.8之前我遇到过这个或类似的错误,但这不是name字段的问题。而且我无法删除数据库中的django_content_types表,因为auth链接到此表。我可以以某种方式解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

因此,确保dev-server和生产服务器在Django 1.8上运行后,一切运行良好。我在启动脚本的环境路径中遇到了一些困惑。