Model or Form class

52 views
Skip to first unread message

Denis Makarov

unread,
Mar 10, 2016, 9:01:50 PM3/10/16
to Django users
Hello guys! In whitch cases need to use models.Model class  and in whitch forms.Form?

Don't understand it readed the documentation.

Bob Gailer

unread,
Mar 10, 2016, 11:06:01 PM3/10/16
to Django users


On Mar 10, 2016 9:01 PM, "Denis Makarov" <makarov...@gmail.com> wrote:
>
> Hello guys! In whitch cases need to use models.Model class  and in whitch forms.Form?

Models define tables in a database. Forms assist in creating HTML forms for gathering, valididating and saving user input. Does that help?

Denis Makarov

unread,
Mar 11, 2016, 4:27:11 PM3/11/16
to Django users
You mean, that I must use Models.Model for database and Forms for creating forms both?

пятница, 11 марта 2016 г., 7:06:01 UTC+3 пользователь bob gailer написал:

James Schneider

unread,
Mar 11, 2016, 4:56:34 PM3/11/16
to django...@googlegroups.com

On Mar 10, 2016 9:01 PM, "Denis Makarov" <makarov...@gmail.com> wrote:
>
> Hello guys! In whitch cases need to use models.Model class  and in whitch forms.Form?

Models define tables in a database. Forms assist in creating HTML forms for gathering, valididating and saving user input. Does that help?


Have you been through the official tutorial yet? You can see both models and forms in use with an example and explanations.


-James

Denis Makarov

unread,
Mar 11, 2016, 9:54:15 PM3/11/16
to Django users
I read this, but in tutorial not used forms.Form class. I know how created forms on models.Model and forms.Form. But when I must use first and when second?

суббота, 12 марта 2016 г., 0:56:34 UTC+3 пользователь James Schneider написал:

Tony Flury

unread,
Mar 12, 2016, 8:36:32 AM3/12/16
to Django users
You can use forms.Form when you want to build a custom form which isn't directly connected to a model on the database. For instance one use for a forms.Form is where you are collecting data which will be stored into attributes on different models.

The documentation I think uses forms.ModelForn which is ideal for building forms which directly relate to models in your database.

Reply all
Reply to author
Forward
0 new messages