Data inside not visible in Django Rest Framework

I am using DRF for CRUD operations. In my Project, I have function-based view taking request as parameter. I am aware of the fact that is only applicable for DRF-Specific requests. I am also aware of the fact that it is a QueryDict. I am taking input from HTML form as name, roll and city of a Student. But when I print the (aka QueryDict), I only get csrfmiddlewaretoken and its value and found that other key-value pairs are missing. Where is my other data (i.e roll, name and city)

e.g {"csrfmiddlewaretoken": "JSACyyvAPqNcCPXNZQsNzPcca7ah3N7arkhFM9CuqpNammk6f43wQ4GyGg5QwU6w"}

It was supposed to contain other data fields as well!

In Django, when you render an HTML form manually, the input fields need to have a "name" attribute in order to be processed correctly when the form is submitted. The "name" attribute is used to identify the input field on the server side and associate it with the corresponding data in the request. Without the "name" attribute, Django won't know which form field to assign the submitted value to, and the data won't be processed correctly.

For example, consider the following HTML form:

<form action="/submit" method="post">
  <input type="text" name="username">
  <input type="password" name="password">
  <input type="submit" value="Submit">

In this example, the "name" attributes for the input fields are "username" and "password". When the form is submitted, Django will receive the submitted data and associate the value of the "username" input field with the "username" attribute, and the value of the "password" input field with the "password" attribute.

So, in your case you need "name" attributes for all of your 3 input tags.

Back to Top