We will now create a view for letting users post questions that they need answered.
Django follows Model-View-Template (MVT) pattern separate model, control, and presentation logic and encourage reusability. Models represent the data we'll store in the database. Views are responsible for handling a request and returning a response. Views should not have HTML. Templates are responsible for the body of a response and defining the HTML. This separation of responsibilities has proven to make it easy to write code.
To let users post questions, we'll perform the following steps:
- Make a form to process the questions
- Make a view that uses Django forms to create questions
- Make a template that renders the form in HTML
- Add a
path
to the view
First, let's make the QuestionForm
class.