Dnia 11-03-2011 o 21:39:01 bagheera <neost...@go2.pl> napisał(a):
Dnia 11-03-2011 o 21:29:29 greenie2600 <greenie2...@gmail.com>
napisał(a):
bagheera -
I had seen the limit_choices_to parameter, but I thought it controlled
*which* choices are available to the user - not *how many* they're
allowed to choose.
I want to show the user a list of 20 or 30 cuisines, but forbid them
from checking more than three.
Can you show me an example of how I'd use limit_choices_to to limit
the *number* of choices the user can select?
Form validation.
this should work
class RestaurantForm(forms.ModelForm):
cuisines = forms.ModelMultipleChoiceField(Sklep)
class Meta:
model = Restaurant
def clean_sklepy(self):
cuisines_clean = self.cleaned_data[cuisines]
if len(cuisines_clean) > 3:
raise forms.ValidationError('You can't choose more than
three items!')
return cuisines_clean
Sorry, i left some of my code :P But u got the idea.
--
Linux user
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.