from django.views.generic import ListView, DetailView, FormView

from forms import TopicCreateForm, PostCreateForm
from models import Category, Topic, Forum


class CategoryListView(ListView):
    model = Category

class ForumDetailView(DetailView):
    model = Forum

class TopicDetailView(DetailView):
    model = Topic

class TopicCreateView(FormView):
    template_name = 'forums/topic_create.html'
    form_class = TopicCreateForm

    def get_context_data(self, **kwargs):
        context = super(TopicCreateView, self).get_context_data(**kwargs)
        context['forum'] = Forum.objects.get(id=self.kwargs.get('forum_id', None))
        return context


class PostCreateView(FormView):
    template_name = 'forums/post_create.html'
    form_class = PostCreateForm

@@ -149,16 +149,22 @@
 c, Forum
+, Post
 %0A%0A%0Aclass
@@ -754,24 +754,240 @@
 _class = PostCreateForm%0A
+%0A    def get_context_data(self, **kwargs):%0A        context = super(PostCreateView, self).get_context_data(**kwargs)%0A        context%5B'topic'%5D = Topic.objects.get(id=self.kwargs.get('pk', None))%0A        return context%0A

add topic to topic create view context