Зміст курсу
Django: Build Your First Website
Django: Build Your First Website
2. The First Application
4. CRUD Operations
6. Forms and Dynamic URLs
Forms: Validation
Description
python
class Meta
model = Note
: Tells Django that this form is associated with the Note model;fields = ['title', 'content']
: Specifies exactly which fields from the model we want to include in our form.
python
Handling Form Submission (POST method)
Checks if the current request method is POST. If it is, it means the user submitted a form;
Creates a NoteForm instance with the data from the POST request (
request.POST
);Checks if the form is valid using
form.is_valid()
. If the form is valid, it saves the data to the database usingform.save()
.
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 6. Розділ 2