Example #1
0
class ThreadCreateForm(forms.Form):
    title = forms.CharField(label=_('Title'), max_length=255)
    content = forms.CharField(label=_('Content'), widget=forms.Textarea)
    
    def __init__(self, *args, **kwargs):
        super(ThreadCreateForm, self).__init__(*args, **kwargs)
        self.thread = Thread()
        self.post = Post()
    
    def save(self):
        self.thread.title = self.cleaned_data['title']
        self.thread.save()
        
        self.post.thread = self.thread
        self.post.content = self.cleaned_data['content']
        self.post.save()
Example #2
0
 def __init__(self, *args, **kwargs):
     super(ThreadCreateForm, self).__init__(*args, **kwargs)
     self.thread = Thread()
     self.post = Post()