Answer the question
In order to leave comments, you need to log in
django forms and models. What is the difference?
I want to understand whether the forms are related to databases, and if so, why do we need models? Sorry, just trying to figure out django. I didn't find the answer to my question in the documentation.
Answer the question
In order to leave comments, you need to log in
Models are connected to the database, they are needed to represent data in the database in the form of python objects.
Forms - in the general case, they are needed to receive and validate data from the user with which you then do what you need. A special case is ModelForm, which itself blinds a model object for you from the data received in the form.
The flow is:
User data -> Form -> Model -> DB
https://docs.djangoproject.com/en/3.1/topics/forms...
In the documentation, in principle, there are answers to many questions
Roughly speaking:
Model - your table in the database
Model-based form - Adding (+ validating) a row in the database
If you just started learning Django, start with their example of creating a site and a lot will fall into place: https://docs.djangoproject.com/en/3.1/intro/tutorial01/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question