I'm trying to change the label of the fields that are required in django form using labels in Meta class . so after writing the code using this doc , i have a problem because the name of the field changes but the -> * character <- stays there .
Code :
from django.utils.translation import gettext_lazy as _
class Meta:
model = ...
fields = ...
widgets = ...
labels = {
'email': _('email (necessary)'),
'username': _('name (necessary)'), # the result of this -> name(necessary)*
}
Template :
{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<h1>USERS REGISTER PAGE IS FOUND!</h1>
<br>
<hr>
<div>
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Join Today</legend>
{{ form|crispy }}
</fieldset>
<div class="form-group">
<button type="submit" class="btn btn-outline-info">Sign Up</button>
</div>
</form>
<div class="border-top pt-3">
<small class="text-muted">
Already Have An Account ? <a class="ml-2" href="{% url 'users-login' %}">Sign In</a>
</small>
</div>
</div>
{% endblock content %}
so , how can I remove this annoying * ?
The root cause here was apparently the django-crispy-forms
package being used for rendering the form.
Its documentation has a section on the "required" asterisks; the easiest, as linked, is to hide the asterisk field; you don't need to change the labels:
.asteriskField {
display: none;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With