[Answered ]-I need to setting author when saving model's instance

2👍

I would recommend overwriting the save() method and passing the user to it like this:

class NewsForm(ModelForm):

    def save(self, author, commit=True):
        # Don't commit the results yet
        news = ModelForm.save(self, commit=False)
        news.author = author
        if commit:
            news.save()
        return news

    class Meta:
            model = News
            exclude = ('pub_date','author',)
👤Wolph

Leave a comment