mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-20 19:01:16 +08:00
make FormMixin generic to allow proper typing for LoginView (#515)
closes #514
This commit is contained in:
12
tests/typecheck/test_views.yml
Normal file
12
tests/typecheck/test_views.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
- case: login_form_form_valid_typechecks
|
||||
main: |
|
||||
from django.contrib.auth.views import LoginView
|
||||
from django.contrib.auth import login as auth_login
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
|
||||
class MyLoginView(LoginView):
|
||||
def form_valid(self, form: AuthenticationForm) -> HttpResponseRedirect:
|
||||
"""Ensure that form can have type AuthenticationForm."""
|
||||
form.get_user()
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
Reference in New Issue
Block a user