Now that we can store the tag data along with other bookmark information, we are ready to create a form for submitting bookmarks to the database. This form will let users specify the bookmark's URL, title, and tags. The process of creating this form is very similar to that of the registration form we created in Chapter 4. In fact, the method explained here can be used to create any HTML form that saves information into the database.
The first step in building our form is defining a class for it. So open the bookmarks/forms.py
file and add the following class to it:
class BookmarkSaveForm(forms.Form): url = forms.URLField( label=u'URL', widget=forms.TextInput(attrs={'size': 64}) ) title = forms.CharField( label=u'Title', widget=forms.TextInput(attrs={'size': 64}) ) tags = forms.CharField( label=u'Tags', required=False, widget=forms.TextInput(attrs={'size': 64}) )
This code should look familiar to you. For each field...