class FeedAddForm forms ModelForm class Meta model Feed fields name sl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class FeedAddForm(forms.ModelForm):
class Meta:
model = Feed
fields = ['name', 'slug', 'private']
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(FeedAddForm, self).__init__(*args, **kwargs)
def save(self):
feed = super(FeedAddForm, self).save(commit=False)
feed.owner = self.user
feed.save()
return feed