title: How can I return an HttpResponse with Django Rest Framework?
body: <p>I'm building an API function that allows the client to sent a GET request with URL parameters, the server receives and process a file based on the given info, and returns a custom file. The good news is I all of the steps working independently!</p>
  
  <p>I was able to get everything working inside the <code>def get_query</code> function <strong>except</strong> returning the HttpResponse. The function requires a Queryset response (makes sense I guess..). I figured I needed another function so I could return the HttpResponse, so I created <code>def send_file</code>. I'm not sure how to call this function and right now it just skips it. </p>
  
  <p>views.py.</p>
  
  <pre><code>class SubFileViewSet(viewsets.ModelViewSet):
  
      queryset = subfiles.objects.all()
      serializer_class = SubFilesSerializer
      permission_classes = (permissions.IsAuthenticatedOrReadOnly,
                            IsOwnerOrReadOnly,)
  
      def send_file(self, request):
  
          req = self.request
          make = req.query_params.get('make')
          model = req.query_params.get('model')
          plastic = req.query_params.get('plastic')
          quality = req.query_params.get('qual')
          filenum = req.query_params.get('fileid')
          hotend = req.query_params.get('hotendtemp')
          bed = req.query_params.get('bedtemp')
  
          if make and model and plastic and quality and filenum:            
  
              filepath = subfiles.objects.values('STL', 'FileTitle').get(fileid = filenum)
  
              path = filepath['STL']
              title =  filepath['FileTitle']    
  
              '''
              #Live processing (very slow)
              gcode = TheMagic(
                  make=make, 
                  model=model, 
                  plastic=plastic, 
                  qual=quality, 
                  path=path, 
                  title=title, 
                  hotendtemp=hotend,
                  bedtemp=bed)
  
              '''
              #Local data for faster testing
              gcode = "/home/bradman/Documents/Programming/DjangoWebProjects/3dprinceprod/fullprince/media/uploads"
  
              test_file = open(gcode, 'r')
              response = HttpResponse(test_file, content_type='text/plain')
              response['Content-Disposition'] = "attachment; filename=%s" % title
  
  
              print (response)
              return response
  
      def perform_create(self, serializer):
          serializer.save(owner=self.request.user)        
  
  
      def get_queryset(self):
          req = self.request
          make = req.query_params.get('make')
          model = req.query_params.get('model')
          plastic = req.query_params.get('plastic')
          quality = req.query_params.get('qual')
          filenum = req.query_params.get('fileid')
          hotend = req.query_params.get('hotendtemp')
          bed = req.query_params.get('bedtemp')
  
          return self.queryset
          #function proved in here then removed and placed above
          #get_query required a queryset response
  </code></pre>
  
  <p>I have little experience with Django Rest Framework and I'm not sure if there is a better way to implement this, or how I could call the function <code>def send_file</code>?</p>