Workshop
The workshop consists of a set of questions and answers designed to solidify your understanding of the material covered in this hour. Try answering the questions before looking at the answers.
Quiz
1. | What format is a form rendered in if you do not use the as_p, as_ul, or as_table functions? |
2. | How do you set the initial values for a form? |
3. | How to you create a form directly from a model? |
4. | How can you access the value of form elements from within a template? |
Quiz Answers
1. | The form is rendered as a table. |
2. | There are three ways. You can create the form from an instance of an object. You can set the initial attribute of the Fields in the form when you define it. You can pass a dictionary to the Form constructor when you create an instance of the form. |
3. | Call the django.newforms.form_for_model() function and pass it the model class. |
4. | You can use the dot syntax in a template to access form elements; for example, form1.name. |