Skip to content

Instantly share code, notes, and snippets.

View slacy's full-sized avatar

Steve Lacy slacy

  • Mountain View, CA
View GitHub Profile
@slacy
slacy / dynamic_form.py
Created January 24, 2011 21:43
Django Dynamic Form Choices
class CreateItemForm(forms.Form):
categories = forms.MultipleChoiceField(
# Must fill in choices and initial from the DB at runtime
widget=forms.CheckboxSelectMultiple(),
required=False,
)
def __init__(self, *args, **kwargs):
user = kwargs['user']
del kwargs['user']