joestump / django-ajax

A simple framework for creating AJAX endpoints in Django.
http://github.com/joestump/django-ajax
BSD 3-Clause "New" or "Revised" License
260 stars 53 forks source link

Support for ManyToManyFields #48

Open insertjokehere opened 11 years ago

insertjokehere commented 11 years ago

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)
joestump commented 11 years ago

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.