Commits

Anonymous committed 8b68d11

Set user in the form object in views

Comments (0)

Files changed (1)

     if form_class is None:
         form_class = utils.get_profile_form()
     if request.method == 'POST':
-        form = form_class(data=request.POST, files=request.FILES)
+        form = form_class(user=request.user, data=request.POST, files=request.FILES)
         if form.is_valid():
             profile_obj = form.save(commit=False)
             profile_obj.user = request.user
                 form.save_m2m()
             return HttpResponseRedirect(success_url)
     else:
-        form = form_class()
+        form = form_class(user=request.user)
     
     if extra_context is None:
         extra_context = {}