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

@ membership_required def topic_edit ( request , slug , topic_id , template_name = 'groups/topics/topic_form.html' ) : group = get_object_or_404 ( Group , slug = slug ) topic = get_object_or_404 ( GroupTopic , pk = topic_id , group = group , user = request . user ) if ( request . method == 'POST' ) : form = GroupTopicForm ( request . POST , instance = topic ) if form . is_valid ( ) : form . save ( ) return redirect ( request , topic ) else : form = GroupTopicForm ( instance = topic ) return render ( request , template_name , { 'form' : form , 'group' : group , 'topic' : topic } )
returns a group topic form page .