[Answer]-Django form use excluded field

1👍

Its explained well in document model form selecting fields to use
You have to do something like this in your view

...
if request.POST:
        new_char_form = CreateCharacterForm(request.POST)

        if new_char_form.is_valid():
            #save form with commit=False
            new_char_obj = new_char_form.save(commit=False)
            #set user and save
            new_char_obj.user = user
            new_char_obj.save()
            return HttpResponseRedirect('%s/characters/' % user_id)

        else:
            ...
👤Rohan

Leave a comment