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 8914173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:39:23+00:00 2026-06-15T04:39:23+00:00

I have a Django model with a ManyToMany field called images , and a

  • 0

I have a Django model with a ManyToMany field called images, and a simple ModelForm for that model.

I’m trying to post data using jQuery and a very basic UpdateView.

The model’s field

images = models.ManyToManyField(
    RawImage,
    null = True,
)

The form

class PublicDataPoolForm(forms.ModelForm):
    error_css_class = 'error'

    class Meta:
        model = PublicDataPool

The UpdateView

class PublicDataPoolAddDataView(AjaxableResponseMixin, UpdateView):
    model = PublicDataPool
    form_class = PublicDataPool_ImagesForm

    @method_decorator(user_passes_test(lambda u: user_has_active_subscription(u)))
    def dispatch(self, *args, **kwargs):
        return super(PublicDataPoolAddDataView, self).dispatch(*args, **kwargs)

The jQuery posting the data

$.ajax({
    type: 'post',
    dataType: 'json',
    url: '/rawdata/publicdatapools/' + pk + '/add-data/',
    data: {images: [1, 2]}
});

I get a ValidationError because the field images is required. If I print my request.POST in my UpdateView, I get this:

<QueryDict: {u'images[]': [u'1', u'2']}>

I believe the problem is with those [], because I’ve checked with another form that gets posted in a more traditional way, and the request.POST doesn’t have those [] in the field name.

Any idea what I’m missing?

  • 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-15T04:39:23+00:00Added an answer on June 15, 2026 at 4:39 am

    You’ll want to set jQuery.ajaxSettings.traditional = true; on page load so that jquery doesn’t append the [] to the key.

    Source:
    http://forum.jquery.com/topic/jquery-post-1-4-1-is-appending-to-vars-when-posting-from-array-within-array#14737000000691277

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django model TimeThingie with two TimeField s called t1 and t2
I have a Django model which has a foreign key that is optional. I
I have written a custom Django Model Field to store dateutil.relativedelta 's. The field
I want a Django model to have a date field in which the year,
I have a M2M field in my django model project. In my view I
I have a couple of simple objects that have a many-to-many relationship. Django has
I have a Django model representing a simple grocery list, as follows (truncated for
I am trying to add an additional custom field to a django model. I
I have a Django model with a ManyToManyField and I'm trying to iterate the
I want to change a ManyToMany field in a django app. I have the

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.