Skip to content

Instantly share code, notes, and snippets.

@TheBB
Created October 5, 2013 20:50
Show Gist options
  • Save TheBB/6845858 to your computer and use it in GitHub Desktop.
Save TheBB/6845858 to your computer and use it in GitHub Desktop.
class MyForm(form):
def __init__(user, *args, **kwargs):
super(MyForm, self).__init__(*args, **kwargs)
self.fields['character'] = forms.ChoiceField(
choices=[(c.id, c.name) for c in Character.objects.filter(...)]
)
# In view
def my_view(request):
form = MyForm(request.user, ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment