我正在使用,
的Django == 1.8 django的登记-终极版== 1.1
提交注册表后,我收到了完整性错误。
我实际上是在关注教程。
IntegrityError at /accounts/register/
NOT NULL constraint failed: registration_registrationprofile.activated
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.8
Exception Type: IntegrityError
Exception Value:
NOT NULL constraint failed: registration_registrationprofile.activated
Exception Location: /home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py in execute, line 318
Python Executable: /home/bhanu_prakash/Desktop/ENV1/bin/python
Python Version: 3.4.0
Python Path:
['/home/bhanu_prakash/Desktop/ENV1/automation',
'/home/bhanu_prakash/Desktop/ENV1/lib/python3.4',
'/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/plat-x86_64-linux-gnu',
'/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages']
Server time: Tue, 12 Apr 2016 12:14:10 +0000
请检查下面的追溯
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.8
Python Version: 3.4.0
Installed Applications:
('django.contrib.admin',
'registration',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'API')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/views.py" in dispatch
79. return super(RegistrationView, self).dispatch(request, *args, **kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/views.py" in post
35. return self.form_valid(request, form)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/views.py" in form_valid
82. new_user = self.register(request, **form.cleaned_data)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/backends/default/views.py" in register
92. request=request,
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/models.py" in create_inactive_user
91. registration_profile = self.create_profile(new_user)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/registration/models.py" in create_profile
115. activation_key=activation_key)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/manager.py" in manager_method
127. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/query.py" in create
348. obj.save(force_insert=True, using=self.db)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/base.py" in save
710. force_update=force_update, update_fields=update_fields)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/base.py" in save_base
738. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/base.py" in _save_table
822. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/base.py" in _do_insert
861. using=using, raw=raw)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/manager.py" in manager_method
127. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/query.py" in _insert
920. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
963. cursor.execute(sql, params)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/utils.py" in __exit__
97. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/utils/six.py" in reraise
658. raise value.with_traceback(tb)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/home/bhanu_prakash/Desktop/ENV1/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py" in execute
318. return Database.Cursor.execute(self, query, params)
Exception Type: IntegrityError at /accounts/register/
Exception Value: NOT NULL constraint failed: registration_registrationprofile.activated
可能是一些数据库问题。
为参考建模代码
class RegistrationProfile(models.Model):
ACTIVATED = "ALREADY_ACTIVATED"
user = models.ForeignKey(UserModelString(),unique=True, verbose_name=_('user'))
activation_key = models.CharField(_('activation key'), max_length=40)
objects = RegistrationManager()
class Meta:
verbose_name = _('registration profile')
verbose_name_plural = _('registration profiles')
def __str__(self):
...
答案 0 :(得分:1)
尝试删除db.sqlite3,然后再次运行./manage.py migrate
。您正在使用django-registration-redux==1.1
,并且使用1.2创建表。