我从一个教程服从testinggoat.com(Win7、Django 1.11、python3.6.1)以及在尝试手动访问本地站点时遇到一些问题。当我运行python manage.py runserver并在Chrome浏览器窗口中打开localhost:8000时,我得到以下错误:
django.db.utils.OperationalError: no such table: accounts_user
浏览器窗口中的输出显示有一个Error during template rendering
下面是它试图呈现的模板片段:
{% if user.email %}
{% else %}
method="POST"
action="{% url 'send_login_email' %}">
Enter email to log in:
{% csrf_token %}
{% endif %}
{% if messages %}
{% for message in messages %}
{% if message.level_tag == 'success' %}
{% else %}
{% endif %}
{% endfor %}
{% endif %}
我相信这个问题来自{% user.email %},因为这些特定的错误直到我将它们添加到模板中才出现。不过,有一些事情似乎很奇怪:我所有的功能测试都顺利通过了。
我对{% messages %}没有任何问题。对不起,我没有
知道这些{% things %}被称为。
makemigrations和{}没有帮助。
以下是accounts应用程序的views.py:
^{pr2}$
下面是accounts应用程序的models.py:from django.contrib import auth
from django.db import models
import uuid
auth.signals.user_logged_in.disconnect(auth.models.update_last_login)
class User(models.Model):
email = models.EmailField(primary_key=True)
REQUIRED_FIELDS = []
USERNAME_FIELD = 'email'
is_anonymous = False
is_authenticated = True
class Token(models.Model):
email = models.EmailField()
uid = models.CharField(default=uuid.uuid4, max_length=40)