title: class based views, response headers and CORS
body: <p>Apologies if this is a very basic question but I am relatively new to web development and have been stuck on this for most of today on the below issues - any help is greatly appreciated.</p>
  
  <p><strong>1. Generic class based views</strong></p>
  
  <p>I'm really just going through the tutorial here and modifying this for my own basic needs and have ended up with the basic view as follows:</p>
  
  <pre><code>class EList(generics.ListCreateAPIView):
      model = trax 
      #permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
      serializer_class = TraxSerializer
  </code></pre>
  
  <p>What will be posting to this api is an external service which I am also building which means I am running into cross origin resource sharing issues (CORS). Ideally I would need to set the headers to something like <code>["Access-Control-Allow-Origin"] = "*"</code> but am unsure how to do this using these generic class based views even after searching for this. Is this possible and I have just been looking in the wrong place?</p>
  
  <p>I had found <a href="https://groups.google.com/forum/#!topic/django-rest-framework/l-NZr7uIznw" rel="nofollow">this post</a>, where Tom had mentioned that it was possible, but can't seem to work this into my above view which leads me on to the next step</p>
  
  <p><strong>2.) Class based views</strong></p>
  
  <p>To try and get a bit more flexibility around setting the headers and to try out what I found in the post on CORS I decided to revert back to a standard class based view as below:</p>
  
  <pre><code>class EList(APIView):
      """
      List all snippets, or create a new snippet.
      """
      def get(self, request, format=None):
          trax = trax.objects.all()
          serializer = TraxSerializer(trax, many=True)
          return Response(serializer.data)
      def post(self, request, format=None):  
          serializer = TraxSerializer(data=request.DATA)
          if serializer.is_valid():
              serializer.save()
              return Response(serializer.data, status=status.HTTP_201_CREATED)
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>However I get the following error:</p>
  
  <blockquote>
    <p>Cannot apply DjangoModelPermissions on a view that does not have
    <code>.model</code> or <code>.queryset</code> property.</p>
  </blockquote>
  
  <p>Is there any way around this so I can try out setting response headers here? This is my current permissions as well:</p>
  
  <pre><code>'DEFAULT_PERMISSION_CLASSES': [
          'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
      ]
  </code></pre>
  
  <p>Thanks for any help,</p>