Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8539157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:17:48+00:00 2026-06-11T11:17:48+00:00

So in this formset the first field saves & updates just fine… but when

  • 0

So in this formset the first field saves & updates just fine… but when I want to add a new object, it doesn’t work out so well.

#Views.py
def edit_auto(request):
car = Auto.objects.filter(user=request.user)
CarFormSet = modelformset_factory(Auto, form=AutoForm, max_num=3)

if request.method == 'POST':
    formset = CarFormSet(request.POST, request.FILES, queryset=car)
    if formset.is_valid():
        formset.save(commit=False)
        formset.user = request.user
        formset.save()

    return render_to_response('manage_users.html', {'message':'Success! The user has been updated!'}, context_instance=RequestContext(request))
else:
            formset = CarFormSet(queryset=car)
return render_to_response('mycar.html', locals(), context_instance=RequestContext(request))

#forms.py
class AutoForm(forms.ModelForm):
    class Meta:
        model = Auto
        user = Auto.user
        exclude = ('user',)

Is it something in the template? If it was a single instance of the form, form.user = request.user normally saves but this doesn’t. Any suggestions? Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:17:49+00:00Added an answer on June 11, 2026 at 11:17 am

    For the user-assigning step, just iterate over the formset.

    ...
    if request.method == 'POST':
        formset = CarFormSet(request.POST, request.FILES, queryset=car)
        if formset.is_valid():
            formset.save(commit=False)
            for form in formset:
                form.user = request.user
            formset.save()
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an edit object view that contains a formset(one or many if this
I hope this question has not been asked yet, but I want to know
this is my first question in here, and I would like to ask if
This should be a simple one: I have an observableArray object called To in
I posted this question on the django-users list, but haven't had a reply there
how do you use model formset in Django? When you do this: from django.forms.models
I'm using a formset with can_delete=True. I want to change the widget of the
I know that I can pass formset to inlineformset_factory and this by default takes
as per this SO question Django Passing Custom Form Parameters to Formset im tryin
I am iterating over a formset made of modelforms in my template. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.