summaryrefslogtreecommitdiff
path: root/app/posts/forms.py
blob: f1b996070def1c7e3f45959dcf0b80d22606902d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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']