Skip to content

Instantly share code, notes, and snippets.

@vitorfs

vitorfs/forms.py Secret

Created September 30, 2017 19:04
Show Gist options
  • Save vitorfs/3dd5ed2b3e27b4c12886e9426acf8fda to your computer and use it in GitHub Desktop.
Save vitorfs/3dd5ed2b3e27b4c12886e9426acf8fda to your computer and use it in GitHub Desktop.
from django import forms
from .models import Topic, Post
class NewTopicForm(forms.ModelForm):
message = forms.CharField(
widget=forms.Textarea(
attrs={'rows': 5, 'placeholder': 'What is in your mind?'}
),
max_length=4000,
help_text='The max length of the text is 4000.'
)
class Meta:
model = Topic
fields = ['subject', 'message']
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ['message', ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment