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

Is there any API to change username of an user

Change field label text on Woocommerce login form

User access to login page after authentication

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

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

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

Is there any way to change ttk Label Frame borderwidth?

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

how to remove username field from login page in django userchangeform

Making user.username (or any field) anonymous for certain users

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

Login page with username and password

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

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

Validate Additional User Field in Login with Laravel default Authentication

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

How to change the user_login by the usermeta field of the same User

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

I s there any better way of user authentication in nextjs

Firebase User Registration / Authentication with Username

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

Login User with Firebase Authentication

User login authentication

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

Django-allauth Redirect any unauthenticated user to login page

Add user custom field check to Moodle login page

Firebase login user with custom username

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

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