@membership_required
def topic_create(request, slug, template_name='groups/topics/topic_form.html'):
 group = get_object_or_404(Group, slug=slug)
 if (request.method == 'POST'):
  form = GroupTopicForm(request.POST)
  if form.is_valid():
   topic = form.save(commit=False)
   topic.user = request.user
   topic.group = group
   topic.save()
   return redirect(request, topic)
 else:
  form = GroupTopicForm()
 return render(request, template_name, {'form': form, 'group': group})

@ membership_required def topic_create ( request , slug , template_name = 'groups/topics/topic_form.html' ) : group = get_object_or_404 ( Group , slug = slug ) if ( request . method == 'POST' ) : form = GroupTopicForm ( request . POST ) if form . is_valid ( ) : topic = form . save ( commit = False ) topic . user = request . user topic . group = group topic . save ( ) return redirect ( request , topic ) else : form = GroupTopicForm ( ) return render ( request , template_name , { 'form' : form , 'group' : group } )
create a topic .