В моей форме есть данные, которые я пытаюсь обозначить по-русски, например:
email = forms.CharField(label='ййй')
Проблема возникает, когда метка содержит только неанглийские символы, метка просто исчезает. Интересно, что когда метка содержит хотя бы один английский символ, метка появится, например:
email = forms.CharField(label='йййa')
Работает правильно.
Та же проблема возникает с атрибутами в параметре виджета.
email = forms.CharField(widget=forms.TextInput(attrs = {'placeholder': 'ййй'}))
Это HTML-код шаблона:
{% load widget_tweaks %}
<h2>Sign up</h2>
<form method = "post">
{% csrf_token %}
{% for hidden_field in form.hidden_fields %}
{{ hidden_field }}
{% endfor %}
{% if form.non_field_errors %}
<div class = "alert alert-danger" role = "alert">
{% for error in form.non_field_errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
{% for field in form.visible_fields %}
<div class = "form-group">
{{ field.label_tag }}
{% if form.is_bound %}
{% if field.errors %}
{% render_field field class = "form-control is-invalid" %}
{% for error in field.errors %}
<div class = "invalid-feedback">
{{ error }}
</div>
{% endfor %}
{% else %}
{% render_field field class = "form-control is-valid" %}
{% endif %}
{% else %}
{% if field.name == 'birth_date' %}
{% render_field field class = "form-control date" id = "date" name = "date" %}
{% else %}
{% render_field field class = "form-control" %}
{% endif %}
{% endif %}
{% if field.help_text %}
<small class = "form-text text-muted">{{ field.help_text }}</small>
{% endif %}
</div>
{% endfor %}
<button type = "submit" class = "btn btn-primary">Submit</button>
</form>
Это выходной html-код:
<h2>Sign up</h2>
<form method = "post">
<input type='hidden' name='csrfmiddlewaretoken' value='Q2EvMWMCPrV597OQV8aqJwtC4X1zuSQI9oVdjeZtgzQUYTAYSp5v22cz2zfOZgwn' />
<div class = "form-group">
<input type = "text" name = "email" autofocus required class = "form-control" id = "id_email" />
</div>
<div class = "form-group">
<label for = "id_id_num">Id number:</label>
<input type = "text" name = "id_num" id = "id_id_num" required class = "form-control" maxlength = "9" />
</div>
<div class = "form-group">
<label for = "id_password1">Password:</label>
<input type = "password" name = "password1" required class = "form-control" id = "id_password1" />
<small class = "form-text text-muted"><ul><li>Your password can&#39;t be too similar to your other personal information.</li><li>Your password must contain at least 8 characters.</li><li>Your password can&#39;t be a commonly used password.</li><li>Your password can&#39;t be entirely numeric.</li></ul></small>
</div>
<div class = "form-group">
<label for = "id_password2">Password confirmation:</label>
<input type = "password" name = "password2" required class = "form-control" id = "id_password2" />
<small class = "form-text text-muted">Enter the same password as before, for verification.</small>
</div>
<div class = "form-group">
<label for = "id_first_name">First name:</label>
<input type = "text" name = "first_name" id = "id_first_name" required class = "form-control" maxlength = "30" />
</div>
<div class = "form-group">
<label for = "id_last_name">Last name:</label>
<input type = "text" name = "last_name" id = "id_last_name" required class = "form-control" maxlength = "30" />
</div>
<div class = "form-group">
<label for = "id_birth_date">Birth date:</label>
<input type = "text" name = "birth_date" required id = "date" name = "date" class = "form-control date" />
</div>
<button type = "submit" class = "btn btn-primary">Submit</button>
</form>
Нашел решение, просто добавьте "u" перед строкой, чтобы сделать ее Unicode
email = forms.CharField(label=u'ййй')
Я не могу воспроизвести вашу проблему. Моя будет отображать ййй. Вставьте шаблон HTML и вывод HTML.