@membership_required
def message_edit(request, slug, topic_id, message_id, template_name='groups/messages/message_form.html'):
 message = get_object_or_404(GroupMessage, pk=message_id, is_active=True)
 if (request.method == 'POST'):
  form = GroupMessageForm(request.POST, instance=message)
  if form.is_valid():
   form.save()
   return redirect(request, message.topic)
 else:
  form = GroupMessageForm(instance=message)
 return render(request, template_name, {'group': message.topic.group, 'topic': message.topic, 'message': message, 'form': form})

@ membership_required def message_edit ( request , slug , topic_id , message_id , template_name = 'groups/messages/message_form.html' ) : message = get_object_or_404 ( GroupMessage , pk = message_id , is_active = True ) if ( request . method == 'POST' ) : form = GroupMessageForm ( request . POST , instance = message ) if form . is_valid ( ) : form . save ( ) return redirect ( request , message . topic ) else : form = GroupMessageForm ( instance = message ) return render ( request , template_name , { 'group' : message . topic . group , 'topic' : message . topic , 'message' : message , 'form' : form } )
returns a group message edit form .