python - django-registration (1048, "Column ' last_login' 不能为空")

标签 python django django-registration django-1.9

我正在尝试在我的简单项目中使用 django-registration。

设置.py

# DJANGO REGISTRATION
ACCOUNT_ACTIVATION_DAYS = 7
AUTH_USER_EMAIL_UNIQUE = True
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'example@gmail.com'

网址.py

url(r'^accounts/', include('registration.backends.hmac.urls')),

注册模板:

{% extends "index.html" %}
{% block content %}
<h1>Registration</h1>
<form method="post" action="">
    {% csrf_token %}
    <dl class="register">
    {% for field in form %}
        <dt>{{ field.label_tag }}</dt>
        <dd class="clearfix">{{ field }}
        {% if field.help_text %}<div class="clearfix">{{ field.help_text }}</div>{% endif %}
        {% if field.errors %}<div class="myerrors clearfix">{{ field.errors }}</div>{% endif %}
        </dd>
    {% endfor %}
    </dl>
<input type="submit" value="Sign Up"  class="clearfix">
</form>
{% endblock %}

当我要注册新用户时,出现错误:

Django Version:     1.9c1
Exception Type:     IntegrityError
Exception Value:    (1048, "Column 'last_login' cannot be null")

我不使用“CustomUser”模型。

最佳答案

确保您已为授权应用运行所有迁移。有迁移0005_alter_user_last_login_null.py这使得 last_login 字段可选。

关于python - django-registration (1048, "Column ' last_login' 不能为空"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33847110/

相关文章:

python - 在管道中使用 apache beam 参数

python - Scrapy - 激活项目管道组件 - ITEM_PIPELINES 设置

django - 注册用户后重定向到页面

python - 如何在 django 框架中使用 django 注册?

python - Django-注册。发送的激活链接缺少我的应用名称

Python、子进程、文件路径空格和著名的 'C:/Program' 未被识别为内部或外部命令

python - 使用装饰器将变量带入装饰函数命名空间

mysql - 左加入 Django 模型查询?

javascript - 每篇文章都有一个单独的链接(bootstrap modal、django、jQuery)

python - 如何重定向到 DJANGO 中包含非 ascii 字符的查询字符串 URL?