from django import forms

from discussion.models import Comment, Post, Discussion


class CommentForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'post')
        model = Comment


class PostForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'discussion')
        model = Post


class SearchForm(forms.Form):
    search = forms.CharField()
    discussion = forms.ModelChoiceField(required=False, queryset=Discussion.objects, empty_label='All discussions')
    #class Meta:
    #    exclude = ('discussion', 'slug')
    #    model = Post


from django import forms

from discussion.models import Comment, Post, Discussion


class CommentForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'post')
        model = Comment
        widgets = {
            'body' : forms.Textarea(attrs={'placeholder' : 'Reply to this conversation'}),
        }


class PostForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'discussion')
        model = Post
        widgets = {
            'body' : forms.Textarea(attrs={'placeholder' : 'Start a conversation'}),
        }

class SearchForm(forms.Form):
    search = forms.CharField()
    discussion = forms.ModelChoiceField(required=False, queryset=Discussion.objects, empty_label='All discussions')
    #class Meta:
    #    exclude = ('discussion', 'slug')
    #    model = Post
    
Set widgets for textareas so we can set placeholder attribute
Set widgets for textareas so we can set placeholder attribute

  from django import forms
  
  from discussion.models import Comment, Post, Discussion
  
  
  class CommentForm(forms.ModelForm):
      class Meta:
          exclude = ('user', 'post')
          model = Comment
+         widgets = {
+             'body' : forms.Textarea(attrs={'placeholder' : 'Reply to this conversation'}),
+         }
  
  
  class PostForm(forms.ModelForm):
      class Meta:
          exclude = ('user', 'discussion')
          model = Post
- 
+         widgets = {
+             'body' : forms.Textarea(attrs={'placeholder' : 'Start a conversation'}),
+         }
  
  class SearchForm(forms.Form):
      search = forms.CharField()
      discussion = forms.ModelChoiceField(required=False, queryset=Discussion.objects, empty_label='All discussions')
      #class Meta:
      #    exclude = ('discussion', 'slug')
      #    model = Post
+     
- 
- 
Set widgets for textareas so we can set placeholder attribute
## Code Before:
from django import forms

from discussion.models import Comment, Post, Discussion


class CommentForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'post')
        model = Comment


class PostForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'discussion')
        model = Post


class SearchForm(forms.Form):
    search = forms.CharField()
    discussion = forms.ModelChoiceField(required=False, queryset=Discussion.objects, empty_label='All discussions')
    #class Meta:
    #    exclude = ('discussion', 'slug')
    #    model = Post


## Instruction:
Set widgets for textareas so we can set placeholder attribute
## Code After:
from django import forms

from discussion.models import Comment, Post, Discussion


class CommentForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'post')
        model = Comment
        widgets = {
            'body' : forms.Textarea(attrs={'placeholder' : 'Reply to this conversation'}),
        }


class PostForm(forms.ModelForm):
    class Meta:
        exclude = ('user', 'discussion')
        model = Post
        widgets = {
            'body' : forms.Textarea(attrs={'placeholder' : 'Start a conversation'}),
        }

class SearchForm(forms.Form):
    search = forms.CharField()
    discussion = forms.ModelChoiceField(required=False, queryset=Discussion.objects, empty_label='All discussions')
    #class Meta:
    #    exclude = ('discussion', 'slug')
    #    model = Post
    