Important Info & Conclusion:
Django can be bit confusing, but it becomes lot easier to understand through coding and lot of practice.
In this book, we have successfully converted our
Doggy Day Care Center project
into a
Django Web Application
. I have covered the
Home Page
,
Log In Page
and the
Contact Us
page and would like to leave the
Create a New profile page
for you all to practice. Well, I can give three hints:
- The syntax for inserting new data into a model is:
model_name ( column1 = “
data
”, column2 = “
data
”, column3 =
123
……… )
(stated in section 5.3)
(please refer to previous sections)
-
As you may recall, we created few drop down lists with the help of <select>
tag in createNewProfile.html
(code present in chapter 2, section 2.3). To create a similar drop down list in Django
form
we should follow the steps below:
Step 1:
Create a
list
of choices. This
list
is a collection of
tuples
and these tuple is made of
key-value pairs
.
Example:
STATE= [
('cal', 'California'),
('ny', 'New York'),
('tx', 'Texas'),
]
Step 2:
Then we pass the
list
of
choices
into our
Django
form
field
for drop down menu.
Example:
state = forms.CharField(widget=forms.
Select
(choices=STATE))
--------------------------------------