I allready put the red asterisk (*) in my registration form. (Like xyres told me [a link] Display a red asterisk (*) in Django forms ). Now i want to do the same in my login form. But i only use the standard Django-Login. My settings.py contains
Do i have to change the default-files in django.contrib.auth?
INSTALLED_APPS = [
# Django apps
'django.contrib.auth',
...]
UPDATE: I tryed to give my urls.py the html like this but it doesn't has an affect on it.
path('accounts/', include('django.contrib.auth.urls'), {'template_name': 'UnserProjekt/accounts/templates/login.html'}),
and my login.html i created new
<form class="login" method="POST" action="/login/">
<h1>LOGIN</h1>
{% csrf_token %}
{% for field in form %}
<style>
login-form label::after {
content: ' *';
color: red;
}
</style>
{{ form.field }}
{% endfor %}
<li><input type="submit" class="logBut" value="Log in"/></li>
</form>
You can override the default Django login template
<form class="login" method="POST" action="/login/">
{% csrf_token %}
{% for field in form %}
/// implement custom output here
{{ form.field }}
{% endfor %}
<li><input type="submit" class="logBut" value="Log in"/></li>
</form>
and use it like this
url(r'^login/$','django.contrib.auth.views.login', {'template_name': '/login.html'})
or you can define it with css like in the example you provided, but target the class or id of the field you want to target. A possible example bellow.
#login-form label::after {
content: ' *';
color: red;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.