summaryrefslogtreecommitdiff
path: root/app/posts/forms.py
blob: 4013040095ec27d25c6f656e26b044d24d04690f (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', 'url', 'template_type', 'update_frequency', 'edit_url', 'date_last_pub']