Options requests
@@ -139,4 +139,5 @@ Maintainers/contributors:
* Arien Tolner - https://github.com/Bounder
* Kevin Brown - https://github.com/kevin-brown
* Martin Cavoj - https://github.com/macav
+* Mjumbe Poe - https://github.com/mjumbewu
@@ -42,6 +42,9 @@ class BulkUpdateModelMixin(object):
``many=True`` ability from Django REST >= 2.2.5.
"""
+ def get_object(self):
+ return self.get_queryset()
+
def bulk_update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
@@ -0,0 +1,16 @@
+from django.test import TestCase
+from django.test.client import RequestFactory
+from simple_app.views import SimpleBulkUpdateAPIView
+class TestBulkUpdateAPIView(TestCase):
+ def test_OPTIONS_request(self):
+ """
+ OPTIONS requests must work for CORS requests. Test that OPTIONS
+ requests aren't failing for simple cases.
+ view = SimpleBulkUpdateAPIView.as_view()
+ request = RequestFactory().options('')
+ response = view(request)
+ self.assertEqual(response.status_code, 200)
@@ -12,6 +12,7 @@ DATABASES = {
INSTALLED_APPS = (
'django_nose',
'rest_framework_bulk',
+ 'simple_app',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
@@ -0,0 +1,5 @@
+from django.db import models
+class SimpleModel (models.Model):
+ contents = models.TextField()
@@ -0,0 +1,6 @@
+from rest_framework_bulk import generics
+from . import models
+class SimpleBulkUpdateAPIView (generics.BulkUpdateAPIView):
+ model = models.SimpleModel