dimanche 13 septembre 2015

Django 1.8 Group CheckboxSelectMultiple from Model / Queryset

I want to do this:

MEDIA_CHOICES = (
    ('Audio', (
        ('vinyl', 'Vinyl'),
        ('cd', 'CD'),
        )
    ),
    ('Video', (
        ('vhs', 'VHS Tape'),
        ('dvd', 'DVD'),
        )
    ),
    ('unknown', 'Unknown'),
    )

but from a queryset. Here's my Model:

class ScoreMsg(models.Model):
    scoremsg = models.TextField(db_column='ScoreMsg',)
    category = models.CharField(db_column='Category', max_length=50,)

I want the CheckboxSelectMultiple in the same layout. I found a solution at Grouped CheckboxSelectMultiple in Django template but that was 3 years ago and am hoping there's another way. Cheers.




Aucun commentaire:

Enregistrer un commentaire