Django for Designers/CRUD: Difference between revisions

Content added Content deleted
imported>Paulproteus
(Remove stray = character)
Line 27: Line 27:


class BookmarkForm(forms.ModelForm):
class BookmarkForm(forms.ModelForm):
class Meta:
class Meta: # Django convention for namespaces
model = Bookmark
model = Bookmark # form fields from Bookmark model fields
</source>
</source>


The generated BookmarkForm class will have a form field for every Bookmark model field--the field type based on some defaults.
<tt>model = Bookmark</tt> ensures that generated BookmarkForm class will have a form field for every Bookmark model field--the field type based on some defaults.


Let's add our BookmarkForm to our views and templates!
Let's add our BookmarkForm to our views and templates!