0

I've tried to do this:

class editPage(forms.Form):
    title = forms.CharField()
    textContent = forms.CharField(widget=forms.Textarea(attrs={'class' : 'textContent'}))
def edit(request,name):
    editForm = editPage()
    editForm.fields["title"].initial = name
    editForm.fields["textContent"].initial = util.get_entry(name)
    return render(request, "encyclopedia/edit.html", {
        "editForm": editPage(),
    })

Everything works correctly, but the values doesn't show in the template. What I should do?

Thanks in advance!

0

Try replacing:

editForm = editPage() editForm.fields["title"].initial = name editForm.fields["textContent"].initial = util.get_entry(name)

with:

editForm = editPage(initial={'title': name, 'textContent': util.get_entry(name)})

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .