How to return data to TemplateView with form?

I purchased a third-party template for Django. I am using a class called SummarizeView(TemplateView) for rendering a page, which includes a form for data entry and a submit button. The form action is called Summarize(). Once the entered text is summarized, I would like to return the results to the same page - SummarizeView page with the summarized text. How may I do this? If I call render with the template name, I receive an error because the third-party layout tags are not recognized.

Thank you.

You typically don’t use TemplateView for displaying and accepting data from forms. You would typically build your view from a FormView.

How much work have you done with Django to this point? Have you worked with Django forms before?

Thank you for your response. I have done minimal work with Django and this is indeed the first project.

Have you worked your way through the Official Django Tutorial? It covers all the fundamentals regarding forms and is always my recommended place to start.

Yes, I did. However, we are using a third-party template that makes the layout and styling very easy and fast. The examples do not address some of the questions and issues I am facing.

Ok, once past the official tutorial, working with CBVs is covered by the docs. Additionally, I also recommend the Classy Class-Based View web site along with the CBV diagrams page for understanding how those views work. (You’ll also need a firm grounding in how Python classes work as well to effectively use them.)

And if you run into any specific issues, we’re here to help.

1 Like