Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Create Post with Input Data | Request Handling
Django: First Dive
course content

Зміст курсу

Django: First Dive

Django: First Dive

1. Get Started
2. Write the First Page
3. Models
4. Working with Database
5. Templates
6. Request Handling

Create Post with Input Data

Note

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
    "<h1>Complete!</h1>"!

Завдання

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
    "<h1>Complete!</h1>"!

Все було зрозуміло?

Секція 6. Розділ 4
toggle bottom row

Create Post with Input Data

Note

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
    "<h1>Complete!</h1>"!

Завдання

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
    "<h1>Complete!</h1>"!

Все було зрозуміло?

Секція 6. Розділ 4
toggle bottom row

Create Post with Input Data

Note

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
    "<h1>Complete!</h1>"!

Завдання

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
    "<h1>Complete!</h1>"!

Все було зрозуміло?

Note

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
    "<h1>Complete!</h1>"!

Секція 6. Розділ 4
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt