django-ajax icon indicating copy to clipboard operation
django-ajax copied to clipboard

Support for ManyToManyFields

Open insertjokehere opened this issue 12 years ago • 1 comments
trafficstars

As far as I can tell (please correct me if I'm wrong), the library at present does not support setting a value for ManyToManyFields on models. Ideally, I would like to be able to pass an array of values to the create endpoint to create a new object, i.e.:

  $.ajax("/ajax/myapp/mymodel.json",{
    data: {'foo':[1,2]}, //jquery handles converting this into the correct format as below
    type: 'POST'});

=> POST /ajax/myapp/mymodel.json?foo=1&foo=2

Class MyModel(models.Model):
    foo = models.ManyToManyField(MyOtherModel)

insertjokehere avatar Sep 23 '13 02:09 insertjokehere

Correct, ManyToManyField's are not supported currently. This is another example of why we should probably consider a pure JSON payload over HTTP POST as well.

joestump avatar Sep 23 '13 06:09 joestump