Всем привет. Не могу понять почему возникает исключение при создании пользователя через админку.
Traceback
Спойлер
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/auth/user/add/
Django Version: 2.0.2
Python Version: 3.6.3
Installed Applications:
['suit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ckeditor',
'ckeditor_uploader',
'Profile',
'Lectures',
'Tikets',
'News',
'Calendar',
'Stream',
'Practice']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in execute
303. return Database.Cursor.execute(self, query, params)
The above exception (UNIQUE constraint failed: Profile_profile.user_id) was the direct cause of the following exception:
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in wrapper
574. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/sites.py" in inner
223. return view(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
62. return bound_func(*args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
58. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
62. return bound_func(*args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
58. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/auth/admin.py" in add_view
100. return self._add_view(request, form_url, extra_context)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/auth/admin.py" in _add_view
127. return super().add_view(request, form_url, extra_context)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in add_view
1553. return self.changeform_view(request, None, form_url, extra_context)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapper
62. return bound_func(*args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/utils/decorators.py" in bound_func
58. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in changeform_view
1450. return self._changeform_view(request, object_id, form_url, extra_context)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in _changeform_view
1491. self.save_related(request, form, formsets, not add)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in save_related
1050. self.save_formset(request, form, formset, change=change)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/contrib/admin/options.py" in save_formset
1038. formset.save()
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/forms/models.py" in save
670. return self.save_existing_objects(commit) + self.save_new_objects(commit)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/forms/models.py" in save_new_objects
804. self.new_objects.append(self.save_new(form, commit=commit))
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/forms/models.py" in save_new
950. obj.save()
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/base.py" in save
729. force_update=force_update, update_fields=update_fields)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/base.py" in save_base
759. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/base.py" in _save_table
842. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/base.py" in _do_insert
880. using=using, raw=raw)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/query.py" in _insert
1125. return query.get_compiler(using=using).execute_sql(return_id)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/models/sql/compiler.py" in execute_sql
1281. cursor.execute(sql, params)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
100. return super().execute(sql, params)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in execute
68. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
77. return executor(sql, params, many, context)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/utils.py" in __exit__
89. raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/utils.py" in _execute
85. return self.cursor.execute(sql, params)
File "/Users/shadow/pyenv/university/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py" in execute
303. return Database.Cursor.execute(self, query, params)
Exception Type: IntegrityError at /admin/auth/user/add/
Exception Value: UNIQUE constraint failed: Profile_profile.user_id
То юзер создается и как положено вместе с профайлом. Помогите разобраться в чем проблема может быть?