Skip to content

Instantly share code, notes, and snippets.

@nephthys
Created November 26, 2014 09:57
Show Gist options
  • Save nephthys/88a429f6d75c4509d1c3 to your computer and use it in GitHub Desktop.
Save nephthys/88a429f6d75c4509d1c3 to your computer and use it in GitHub Desktop.
Disable validation on forms.MultipleChoiceField
from django.forms import MultipleChoiceField
class MultipleChoiceAnyField(MultipleChoiceField):
"""A MultipleChoiceField with no validation."""
def valid_value(self, *args, **kwargs):
return True
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