save() got an unexpected keyword argument 'force_insert'

241 views
Skip to first unread message

Ahmed Khairy

unread,
Apr 21, 2020, 10:56:54 PM4/21/20
to Django users
Hi all, 

Got this unexpected error all of a sudden, how to fix it. 

save() got an unexpected keyword argument 'force_insert'


def register(request):
    if request.method == 'POST':
        form = UserRegisterForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            messages.success(
                request, f'Your account has been created! You are now able to log in')
            return redirect('login')
    else:
        form = UserRegisterForm()
    return render(request, 'register.html', {'form': form})

Motaz Hejaze

unread,
Apr 21, 2020, 11:02:13 PM4/21/20
to Django users
what kind of forms is this ? regular form or model form ?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be6de004-4a69-4346-8a12-99eced8d76a3%40googlegroups.com.

Ahmed Khairy

unread,
Apr 21, 2020, 11:06:15 PM4/21/20
to Django users
Model Form 

UserCreationForm


On Tuesday, April 21, 2020 at 11:02:13 PM UTC-4, Motaz Hejaze wrote:
what kind of forms is this ? regular form or model form ?


On Wed, Apr 22, 2020 at 4:57 AM Ahmed Khairy <ahmed.he...@gmail.com> wrote:
Hi all, 

Got this unexpected error all of a sudden, how to fix it. 

save() got an unexpected keyword argument 'force_insert'


def register(request):
    if request.method == 'POST':
        form = UserRegisterForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            messages.success(
                request, f'Your account has been created! You are now able to log in')
            return redirect('login')
    else:
        form = UserRegisterForm()
    return render(request, 'register.html', {'form': form})

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django...@googlegroups.com.

Motaz Hejaze

unread,
Apr 21, 2020, 11:13:16 PM4/21/20
to Django users
did you define managers ?

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4a164104-3cab-4d97-a6ac-47b9a3ed98dd%40googlegroups.com.

Ahmed Khairy

unread,
Apr 21, 2020, 11:17:56 PM4/21/20
to Django users
What do you mean ? 

Motaz Hejaze

unread,
Apr 21, 2020, 11:23:10 PM4/21/20
to Django users

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/affd82c8-1b8c-46a0-85c0-a3a5c6939abe%40googlegroups.com.
Message has been deleted

Ahmed Khairy

unread,
Apr 21, 2020, 11:35:17 PM4/21/20
to Django users
Thank you so much it is realllllyy helpfull. Fixed it 

Motaz Hejaze

unread,
Apr 21, 2020, 11:50:54 PM4/21/20
to Django users
nice to know, good luck

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3983161c-10b7-4e0d-b2ba-8dbf83e3b890%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages