Skip to content

lxbrvr/django-grouped-choice-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

django-grouped-choice-field

Grouping of model choices by field name.

Tested on Django 1.11 and Python 3.5

Demo

Demo 1 Demo 2

Using

forms.py
class ArticleForm(forms.Form):
    articles = GroupedModelMultipleChoiceField(
        group_by='category__name',
        sort_choices_by='-title',
        queryset=Article.objects.all(),
        widget=forms.CheckboxSelectMultiple,
    )
template.html
{{ form.articles }}
Arguments:
  • group_by - groups choices by specific model field. Supports related fields. Required.
  • sort_choices_by - sorts choices by specific model field. Support a reversed sort with adding to string start '-'. Optional.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages