These are chat archives for django/django

28th
Dec 2016
Michael Ketiku
@mketiku
Dec 28 2016 14:51
With the widget CheckboxSelectMultiple, is there a way to only show the validation_error if none of the group of check-boxes are selected. Currently I have it setup to show a validation error but it shows it for each checkbox that is not selected rather than if none of group of check-boxes are selected . So for example if I have 4 checkboxes the message shows 4 times. Is there a way around this?
Here is my code
            ('heading', django_forms.MultipleChoiceField(
                widget=django_forms.CheckboxSelectMultiple(
                        attrs={
                        'checked': '',
                        'required':'required',
                        'validation_error_msg':'Need to check at least one checkbox in the display menu.'
                        }
                ),
                required=True,
                label='Display',
                choices=(
                    ('shortdescription', 'Short Description'),
                    ('title', 'Title'),
                    ('digest','Digest'),
                    ('all', 'Select All')
                ),
                initial='shortdescription'),
             ),
Michael-J-Ward
@Michael-J-Ward
Dec 28 2016 23:04
Is there a django best practice for filtering against constants that are held on the model? We use the convention outlined here: http://stackoverflow.com/a/12823272/1948982
specifically, when querying from within a related model... so .filter(status=Task.CANCELLED) would create a circular import error