Create Post with Input DataCreate Post with Input Data


The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to Run Code. Use the Submit Task button to solve this task.


Now, let's improve our view to save new posts in the database!

The received context via HTTP request is the request.POST dictionary. The keys of the dictionary is:

Write the View functionality for the POST method with data extracting:

  1. Save the request.POST dictionary into the data variable.
  2. Create the Post class instance named new_post
  3. Assign attributes title and text from data dictionary to the new_post instance.
  4. Save changes in the database.
  5. Return the HttpResponse object passing

Everything was clear?

Section 6. Chapter 4
toggle bottom row