from django.forms import ModelForm from django.forms import ChoiceField from .models import Post class PostUpdateForm(ModelForm): def __init__(self,*args,**kwargs): user = kwargs.pop('user') self.user = user super(PostUpdateForm,self).__init__(*args,**kwargs) def save(self, commit=True): self.instance.user = self.user return super().save(commit=commit) class Meta: model = Post fields = ['title', 'post_status']