Changes between Initial Version and Version 1 of Ticket #17137


Ignore:
Timestamp:
Nov 1, 2011, 3:52:37 PM (13 years ago)
Author:
Aymeric Augustin
Comment:

Fixed formatting -- please use wiki syntax and preview.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17137 – Description

    initial v1  
    1 If form is made using ModelForm and choices of ManyToMany field are limited like this:
     1If form is made using `ModelForm` and choices of `ManyToMany` field are limited like this:
    22
    3 -- snip
    4 models.py:
     3{{{
     4# models.py
    55
    66class Product(models.Model):
     
    88   visibility = models.ManyToManyField(Group, verbose_name="Groups")
    99
    10 
    11 views.py:
     10# views.py
    1211
    1312class ProductForm(forms.ModelForm):
     
    2726       if form.is_valid():
    2827           .. do stuff with visibility trusting form.is_valid()
    29 -- snip
     28}}}
    3029
    31 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.
     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.
    3231
    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.
    3433
Back to Top