settings_form = ChangeSettingsForm(request.POST)
Exception Type: IntegrityError
Exception Value:
null value in column "user_id" violates not-null constraint
DETAIL: Failing row contains (29, t, t, t, null).
settings_form = ChangeSettingsForm(request.POST) # , instance=request.user
if request.method == 'POST': # Возможно не нужно
if settings_form.is_valid():
setting = settings_form.save(commit=False)
setting.user = request.user
setting.save()
Request Method: POST
Request URL: http://127.0.0.1:8000/ru/explorer/user-settings/9/
Django Version: 3.0.4
Exception Type: IntegrityError
Exception Value:
duplicate key value violates unique constraint "explorer_objectsofsurveillance_user_id_0cf4da67_uniq"
DETAIL: Key (user_id)=(9) already exists.
Спасибо!