mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-10 19:57:09 +03:00
Fix signature for UserUpdateView.get_object
This commit is contained in:
parent
dd15c83977
commit
a8105bdc9f
|
@ -1,5 +1,6 @@
|
|||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.db.models import QuerySet
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import DetailView
|
||||
|
@ -28,12 +29,12 @@ class UserUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
|
|||
fields = ["name"]
|
||||
success_message = _("Information successfully updated")
|
||||
|
||||
def get_success_url(self):
|
||||
def get_success_url(self) -> str:
|
||||
# for mypy to know that the user is authenticated
|
||||
assert self.request.user.is_authenticated
|
||||
return self.request.user.get_absolute_url()
|
||||
|
||||
def get_object(self):
|
||||
def get_object(self, queryset: QuerySet | None=None) -> User:
|
||||
return self.request.user
|
||||
|
||||
|
||||
|
@ -43,7 +44,7 @@ user_update_view = UserUpdateView.as_view()
|
|||
class UserRedirectView(LoginRequiredMixin, RedirectView):
|
||||
permanent = False
|
||||
|
||||
def get_redirect_url(self):
|
||||
def get_redirect_url(self) -> str:
|
||||
{%- if cookiecutter.username_type == "email" %}
|
||||
return reverse("users:detail", kwargs={"pk": self.request.user.pk})
|
||||
{%- else %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user