First, thanks to all who have been helping me cut my teeth on Django/
Python.
I have been trying to get the above widget to display "nicely" in my
HTML. Here's what I have...
FORMS.PY
class RegistrationForm(forms.Form)
...
role = forms.ChoiceField(choices=[(c.id, c.description) for c in
RoleType.objects.all()], widget=CheckboxSelectMultiple)
( I've also tried "role = forms.CheckboxSelectMultiple(choices=[(c.id,
c.description) for c in RoleType.objects.all()])" )
regform= RegistrationForm(request.POST)
MODELS.PY
class RoleType(models.Model):
name = models.CharField(maxlength=50)
description = models.CharField(maxlength=100, blank=True)
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True, editable=False)
def __str__(self):
return self.name
class Admin:
list_display = ('name', 'description')
search_fields = ['name', 'description']
class Meta:
db_table = 'role_types'
verbose_name = 'Role Type'
verbose_name_plural = 'Role Types'
I want each of the records on RoleType to display as a check box on my
HTML form. When i display them on the form using {{ regform.role }},
they each display with an <li> tag and are not displayed orderly.
Ideally, I'd like eliminate the <li> tag and put them in 3 columns by
X rows (probably using a table), although I'd settle for 1 column by X
rows . Any help with the CheckboxMultipleSelect?
Thanks,
Jim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---