from django import forms
from .models import Post, Comment

class PostForm(forms.ModelForm):
    class Meta:
        model = Post
        fields = ('title', 'body')

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['body'].widget.attrs.update({'class': 'materialize-textarea'})

class CommentForm(forms.ModelForm):
    class Meta:
        model = Comment
        fields = ('author','body',)
    
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['body'].widget.attrs.update({
            'class': 'materialize-textarea',
            'id': 'data-comment_body'})
        self.fields['author'].widget.attrs.update({
            'id': 'data-comment_author'
        })