I have a form that has a field:
class ProfileEditForm(forms.Form):
nickname = forms.CharField(max_length=30, label=_('Your nickname'), required=False)
Then in a template I want to put a user's nickname value. I am using django-widget-tweaks
.
{% load widget_tweaks %}
<label>Your nickname</label> {{ form.nickname|append_attr:"value:"|add:"request.user" }}
In this case I get an empty string instead of the value.
<label>Your nickname</label> {{ form.nickname|append_attr:"value:request.user" }}
And in this case I get a string "request.user" instead of the value of request.user
.
How can I add a value from my database to this field?