1. jordanreiter
  2. django-profiles

Commits

Jordan Reiter  committed 8b68d11

Set user in the form object in views

  • Participants
  • Parent commits f00b015
  • Branches default

Comments (0)

Files changed (1)

File profiles/views.py

View file
     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 = {}