Created
November 26, 2014 09:57
-
-
Save nephthys/88a429f6d75c4509d1c3 to your computer and use it in GitHub Desktop.
Disable validation on forms.MultipleChoiceField
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.forms import MultipleChoiceField | |
class MultipleChoiceAnyField(MultipleChoiceField): | |
"""A MultipleChoiceField with no validation.""" | |
def valid_value(self, *args, **kwargs): | |
return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from .fields import MultipleChoiceAnyField | |
class ObjectForm(forms.ModelForm): | |
categories = MultipleChoiceAnyField(required=False, \ | |
widget=forms.CheckboxSelectMultiple) | |
# [...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment