Skip to content

Instantly share code, notes, and snippets.

@sorki
Created July 20, 2010 19:19
Show Gist options
  • Save sorki/483411 to your computer and use it in GitHub Desktop.
Save sorki/483411 to your computer and use it in GitHub Desktop.
def custom_create(request, *args, **kwargs):
''' update __init__ of the form class to use current user as initial '''
form_class = kwargs['form_class']
class custom_class(form_class):
def __init__(self, *args, **kwargs):
kwargs['initial'] = {'user': request.user.id}
return super(custom_class, self).__init__(*args, **kwargs)
kwargs['form_class'] = custom_class
return create_update.create_object(request, *args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment