#9769: ManyToManyField Widget: saving object does not work
---------------------------+------------------------------------------------
Reporter: sindrero | Owner: nobody
Status: new | Milestone: post-1.0
Component: Uncategorized | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 0 |
---------------------------+------------------------------------------------
In our application, we are unable to save a ManyToManyField, using the
standard webform widgit. MultipleSelectChecbox also does not work. The
scalar_properties, remain an empty list when objects are added through the
webform. All other fields are properly saved.
When examining the ''request.POST'' object, I se that a numeric value is
returned. However request.POST includes only ONE numeric value, when it
SHOULD have returned several. The number returned, is always equal to the
numbering of the last selected element in the list. (The last element in
the list is named 1, the second last is named 2 an so on.) There seems to
be no way of extracting all objects that are actually selected out from
the returned number.
Example code (simplification of our aplication):
in models.py, we have somthing like:
{{{
...
class Calculation(models.Model):
...
scalar_properties = fields.ManyToManyField("ScalarProperty")
...
class ScalarProperty(models.Model)
...
}}}
in views.py we have:
{{{
def edit(request, ...):
instance = ... # The original object, before editing
if request.POST.method == "GET":
# Create form:
....
elif request.POST.method == "POST":
# Save object from form:
calc = forms.CalculationForm(request.POST,
instance=instance).save(commit=False)
...
calc.save()
# Redirect:
...
...
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/9769>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---