Merge pull request #3012 from Andrew-Chen-Wang/patch-8

Use self.request.user instead of second query
This commit is contained in:
Bruno Alla 2021-01-22 09:18:19 +00:00 committed by GitHub
commit 4299f43abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,7 +27,7 @@ class UserUpdateView(LoginRequiredMixin, UpdateView):
return reverse("users:detail", kwargs={"username": self.request.user.username})
def get_object(self):
return User.objects.get(username=self.request.user.username)
return self.request.user
def form_valid(self, form):
messages.add_message(