title: Use custom function in ModelViewSet with Django Rest Framework
body: <p>Django 2.0, Python 3.6, Django Rest Framework 3.8</p>
  
  <p>I'm still pretty new to Django Rest Framework, and I'm trying to wrap my head around the logic for using functions in a viewset (and if this is even the correct place to include a function).</p>
  
  <p>Basically, I would like to send out an email when a user posts something to the api in this specific viewset. I tried using the <code>send_mail</code> function, but have been unsuccessful. I have the following class based view:</p>
  
  <pre><code>class SendInviteView(viewsets.ModelViewSet):
      queryset = models.Message.objects.all()
      serializer_class = serializers.MessageSerializer
  
      @action(methods=['post'], detail=True)
      def send_the_mail(self, request):
          send_mail(
              'Invitation',
              'Try our app!',
              'exampleemail@gmail.com',
              ['examplerecipient@gmial.com'],
              fail_silently=False,
          )
  </code></pre>
  
  <p>[The Model and Serializer are pretty basic, and I don't think will be required for the context of this problem, basically just an EmailField(). I eventually plan to use the input of that email field to replace <code>examplerecipient@gmail.com</code>, but for now I just want to understand how to add functionality to viewsets]</p>
  
  <p>This results in an error when running <code>python manage.py check</code></p>
  
  <p>I have my email client set up through sendgrid and am able to successfully send emails to users who ask to have their passwords reset through <code>rest-auth</code>, but I don't understand how sending an email works outside of that context.</p>
  
  <p>Any help is greatly appreciated.</p>