Is there any way to change username field label in user authentication login page?

user7387275

Right now login page looked like this

I want to change label of username field to Team Name

Note: I'm using builtin LoginView

Lucas Weyne

According to documentation LoginView has an attribute called authentication_form (typically just a form class). Defaults to AuthenticationForm.

You can create a form class that inherits from AuthenticationForm, set the label of the username field and assign it to your LoginView over authentication_form attribute.

forms.py

from django import forms    
from django.contrib.auth.forms import AuthenticationForm, UsernameField


class CustomAuthenticationForm(AuthenticationForm):
    username = UsernameField(
        label='Team Name',
        widget=forms.TextInput(attrs={'autofocus': True})
    )

views.py

from django.contrib.auth.views import LoginView

from .forms import CustomAuthenticationForm


class CustomLoginView(LoginView):
    authentication_form = CustomAuthenticationForm

urls.py

urlpatterns = [
    path('login/', CustomLoginView.as_view(), name='login'),
]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

User access to login page after authentication

Firebase login user with custom username

Is there any way to change view of Django-rest-auth of login?

Is there any way to change datatype of a field in Firestore?

Change field label text on Woocommerce login form

Is there any API to change username of an user

how to remove username field from login page in django userchangeform

Validate Additional User Field in Login with Laravel default Authentication

Is there any way to login to Django admin interface using username or email?

Is there any way to show a field on a listing page in Wagtail admin?

I want to see the login page first even any user want access any other page need to redirect to login page in spring security

Any way to make "const {user, userId} = this.state" work if user references username and userId references id

Is there any way to change the keyboard layout (English - Arabic) using C# even if I force the user to refresh the page?

Is there any way to change label names in Qlik Sense?

I can't change any user settings with my login, why?

is there any way that user can click on label that would popup menu bar

Is there any way to return battery percentage in the username field in Windows?

How do I change the ASP.NET MVC default login page to login by username instead of email address?

Login page with username and password

Add user custom field check to Moodle login page

User login authentication

Firebase User Registration / Authentication with Username

As a user, is there any way to change the "confinement" of a snap package?

Best way to redirect user to Login page on cache lost

Putting username of logged in user as label in django form field

Login user for a custom user model with email as username field

Login User with Firebase Authentication

Is there any way to change the font size for Chart title, Legend and the data label?

Is there any way to change the text in an input field without typing it in manually?