7.4.2 Creating StartupForm
and NewsLinkForm
As with PostForm
, we can use ModelForm
inheritance to quickly create the forms for Startup
and Newslink
model classes in /organizer/forms.py
, shown in Example 7.29.
organizer/forms.py
in e90ec17deb
4 from .models import NewsLink, Startup, Tag 5 6 7 class NewsLinkForm(forms.ModelForm): 8 class Meta: 9 model = NewsLink 10 fields = '--all--' 11 12 13 class StartupForm(forms.ModelForm): 14 class Meta: 15 model = Startup 16 fields = '--all--'
Note that we are going to need to clean the slug
field in our StartupForm
just as we did for TagForm
. In Example 7.30, we copy and paste the function from ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.