My code:
class FileForm(forms.Form):
title = forms.CharField()
content = forms.CharField(
widget=forms.Textarea(attrs={"rows": 15, "cols": 60}))
def edit(request, title):
content = util.get_entry(title)
form = FileForm()
form.title = title
form.content = content
return render(request, 'encyclopedia/edit.html', {
"title": title,
"content":content
})
In edit.html:
<form action="{% url 'save_edit' %}" method="POST">
{% csrf_token %}
<input type="hidden" value="{{ title }}">
<textarea>{{ content }}</textarea>
<input type="submit" value="save">
How do I able to pre-populate the form with the title and content ?
I do not find answer in django documentation or any answer in this platform related to my question.