Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created April 6, 2010 23:06
Show Gist options
  • Save vbmendes/358245 to your computer and use it in GitHub Desktop.
Save vbmendes/358245 to your computer and use it in GitHub Desktop.
class MyForm(forms.ModelForm):
...
def __init__(self, *args, **kwargs):
self.competition = kwargs.pop('competition')
super(MyForm, self).__init__(*args, **kwargs)
def clean(self):
""" Use self.competition here """
...
competition = get_object_or_404(Competition, slug=competition_slug)
form = MyForm(request.POST, competition=competition)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment