I using Django and a generic view “django.views.generic.create_update.create_object”
I have a model form wich i pass to the generic view:
url(r'^add$', create_object, {'template_name':'tpl.html','form_class':MyModelForm,'post_save_redirect':'/'},name = 'add'),
I need to get current user in my ModelForm.save method..
But i can’t find way to get it, please help me to find convinient way?
class MyModelForm(forms.ModelForm):
class Meta:
model = MyModel
def save(self,*a,**b):
MyModel.save(user=request.user) #how can i get here request.user?
In common way the question is – how can i accsess request params in forms passed to generic view.
thnx this helps) I have some problems this syntax and _meta attr and i finished with this
def create_object_with_request(request, *args, **kwargs):