Django: Getting Started Transcripts
Chapter: Posting Data
Lecture: Post introduction
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Up until now, almost everything has been about giving information to the user with just a few hints of accepting data.
0:07
Like a user's credentials when they're logging. This chapter is all about getting information from your users, covering http post and HTML forms.
0:18
When dealing with data submitted from a user, you have to be careful that it conforms to your storage mechanism.
0:24
There are two tools in Django that help you do that. The first our field validators. These are rules you can put on a model's field
0:32
about what form the data in the field can take. Minimum and maximum values are two examples of this. The 2nd Mechanism is database constraints.
0:42
Field validators are enforced by Django as the name implies. Database constraints are enforced by the database.
0:49
You add metadata to your models to get these constraints in place and Django takes care of the corresponding sequel to do the configuration.
0:58
Users submit data to your server through an http post call. To do this, you typically show them an HTML form that they fill in and then they submit.
1:07
All of this is done through a Django view. First a view that shows the form the user fills in and then another view or
1:14
the same one in a different mode to accept and process the data. Once you've got the user's submission, you're going to want to validate it.
1:22
If the data is good, you're going to want to send the user somewhere else. Either back where they came from or some sort of thanks for your data page.
1:30
This is often done by sending the user a redirect, telling the browser where to go next.