django-registration(1048,“Column”last_login“不能为空”) [英] django-registration (1048, "Column 'last_login' cannot be null")

查看:418
本文介绍了django-registration(1048,“Column”last_login“不能为空”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我简单的项目中使用django注册。

I'm trying to use django-registration in my simple project.

# 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'



urls.py



urls.py

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



注册模板:



Registration template:

{% 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 %}

当我注册新用户时,我收到错误:

When I going to register new user, I get an error:

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

我不使用'CustomUser'模型。 >

I don't use 'CustomUser' model.

推荐答案

确保您已经运行了所有的auth应用的迁移。有一个迁移 0005_alter_user_last_login_null .py ,使 last_login 字段可选。

Make sure you have run all the migrations for the auth app. There is a migration 0005_alter_user_last_login_null.py that makes the last_login field optional.

这篇关于django-registration(1048,“Column”last_login“不能为空”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆