WOrking with checkbox Multiple Select FIeld - Django Admin

1,100 views
Skip to first unread message

Bernardo Garcia

unread,
Oct 29, 2016, 6:43:07 PM10/29/16
to Django users
HI, friends.

Someone know how to work with a field that allow perform a multiple selection in a field?, like a checkbox. In django admin,

Thanks :)

M Hashmi

unread,
Oct 30, 2016, 1:26:43 AM10/30/16
to django...@googlegroups.com
Form ModelForm if you need to check a single field then you set it as BooleanField in your models.py but if you need to use kind of condition that requires multiple checkboxes to be True. Then its better to define condition in your view like

models.py
a = models.BooleanField(default=False)
b = models.BooleanField(default=False)
c = models.BooleanField(default=False)

Views.py 
if a and b == True
return "correct".

Makes sense?

Regards,
Mudassar

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/670c3379-cea2-4819-91e8-5fbe804d1c88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pradam programming

unread,
Oct 30, 2016, 8:48:15 AM10/30/16
to django...@googlegroups.com
try to to get all the checked objects using getlist from request store it in a textfield.this is better when you have 20 check boxes then code become too complex and messy

Reply all
Reply to author
Forward
0 new messages