Changes between Initial Version and Version 1 of Ticket #17137
- Timestamp:
- Nov 1, 2011, 3:52:37 PM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #17137 – Description
initial v1 1 If form is made using ModelForm and choices of ManyToManyfield are limited like this:1 If form is made using `ModelForm` and choices of `ManyToMany` field are limited like this: 2 2 3 -- snip 4 models.py: 3 {{{ 4 # models.py 5 5 6 6 class Product(models.Model): … … 8 8 visibility = models.ManyToManyField(Group, verbose_name="Groups") 9 9 10 11 views.py: 10 # views.py 12 11 13 12 class ProductForm(forms.ModelForm): … … 27 26 if form.is_valid(): 28 27 .. do stuff with visibility trusting form.is_valid() 29 -- snip 28 }}} 30 29 31 is_valid() allows values for ManyToManyselections outside what is specified in the form as long as there exists corresponding ID in the database. Obviously the submitted form needs to be modified outside standard browser UI.30 `is_valid()` allows values for `ManyToMany` selections outside what is specified in the form as long as there exists corresponding ID in the database. Obviously the submitted form needs to be modified outside standard browser UI. 32 31 33 is_valid()should compare selections against .choices, not against what exists in the database.32 `is_valid()` should compare selections against .choices, not against what exists in the database. 34 33