Created
July 20, 2010 19:19
-
-
Save sorki/483411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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