Django 2.0 操作错误:游标“_django_curs_139683611834112_1”不存在

Ali*_*Ali 5 django operational cursor python-3.x

错误的子标题是:

“模板渲染时出错

在 .../base.html 第 0 行的错误

游标“_django_curs_139683611834112_1”不存在

目前在运行带有 docker 的 Ubuntu 的服务器上使用 Django 2.0 和 Python 3.6。通过以下流加载空白 URL 时发生错误:

网址.py:

from dashboard2.account_views_new import AccountView

'''urlpatterns =             [                                  
    url(r'^$', AccountView.as_view(), name='home'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Run Code Online (Sandbox Code Playgroud)

意见:

class AccountView(TemplateView):
    template_name = 'fv1/dash_nav.html'

    def get(self, request):
        this_form = forms.ThisForm()
        that_form = forms.ThatForm()
        forms = Form.objects.all()
        things = Things.objects.all()

        return render(request, self.template_name)

    def post(self, request):

        this = that1.objects.all()
        that = this1.objects.all()

        return render(request, self.template_name, {data})
Run Code Online (Sandbox Code Playgroud)

base.html(在第 0 行抛出错误):

<!-- update this to include headers and such in jynja -->
<!DOCTYPE html>
<html lang="en">
{%  load static %}
<head>
Run Code Online (Sandbox Code Playgroud)

是什么产生了这个错误?

小智 0

这个问题最简单的解决方案

  1. 备份您的数据库
  2. 删除所有应用程序迁移文件夹中的所有文件(__ init __ .py 除外)
  3. 如果使用 Docker 删除数据库卷,则 删除您的数据库
  4. 重新创建数据库
  5. 跑步$Python manage.py makemigrations
  6. 跑步$Python manage.py migrate
  7. 恢复您的数据库备份
  8. 好好享受