internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-json-api/django-rest-framework-json-api

Issue:
deprecate MultipleIDMixin
Add (Pending?)DeprecationWarning `MultipleIDMixin` which does not comply with the [JSON:API specification for filtering](http://jsonapi.org/format/#fetching-filtering). If you want to get a collection based on a list of IDs, use `?filter[id.in]=id1,id2,...idN` with the `DjangoFilterBackend` filter.


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/mixins.py b/rest_framework_json_api/mixins.py
--- a/rest_framework_json_api/mixins.py
+++ b/rest_framework_json_api/mixins.py
@@ -1,12 +1,28 @@
 """
 Class Mixins.
 """
+import warnings
 
 
 class MultipleIDMixin(object):
     """
     Override get_queryset for multiple id support
+
+    .. warning::
+
+        MultipleIDMixin is deprecated because it does not comply with http://jsonapi.org/format.
+        Instead add :py:class:`django_filters.DjangoFilterBackend` to your
+        list of `filter_backends` and change client usage from:
+        ``?ids[]=id1,id2,...,idN`` to ``'?filter[id.in]=id1,id2,...,idN``
+
     """
+    def __init__(self, *args, **kwargs):
+        warnings.warn("MultipleIDMixin is deprecated. "
+                      "Instead add django_filters.DjangoFilterBackend to your "
+                      "list of 'filter_backends' and change client usage from: "
+                      "'?ids[]=id1,id2,...,idN' to '?filter[id.in]=id1,id2,...,idN'",
+                      DeprecationWarning)
+        super(MultipleIDMixin, self).__init__(*args, **kwargs)
 
     def get_queryset(self):
         """


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
move isort and flake8 tests to the top
isort and flake8 tests are not run until all other tests. They should go first in .travis.yml. Also make isort and flake8 tests part of the tox testenv commands.


Discussion:
Technically they should run in parallel but usually there are queued up on travis. So moving flake8 and isort up is certainly a good idea.
We could also do isort and flake8 check in one run using [flake8-isort](https://github.com/gforcada/flake8-isort) which would improve those checks.

Maybe even better is to check flake8 and isort before they are even committed with pre-commit hooks e.g. using https://pre-commit.com/
Let's start with fixing tox.ini to include flake8 and isort as the first tests in the main testenv, maybe documenting developer guidelines and adding a local pre-push or pre-commit hook.

(deleted stuff about tox-travis which is already there, d'oh!)

I can at least make sure documenting running tox w/flake8 and isort locally before pushing happens.
Maybe add:
```
before_script:
  - tox -e flake8-isort
``` 
and remove from the matrix:
```
    - python: 3.6
      env: TOXENV=flake8
    - python: 3.6
      env: TOXENV=isort
```
so if the flake8-isort fails, then don't waste time running all the other script steps.
not sure... I still see some value when I have flaking errors and the test still runs and might fail on a particular Python version I can fix both issues at the same time. Otherwise I have to fix the flaking error and then push again and wait till the CI runs through.

Let's just keep it in moving up the isort and flake8 up the list I think that's good enough. Documenting is also a good thing for sure.

Resolving patch:
diff --git a/example/views.py b/example/views.py
--- a/example/views.py
+++ b/example/views.py
@@ -1,12 +1,12 @@
 import rest_framework.exceptions as exceptions
 import rest_framework.parsers
 import rest_framework.renderers
+from django_filters import rest_framework as filters
 from rest_framework.filters import SearchFilter
 
 import rest_framework_json_api.metadata
 import rest_framework_json_api.parsers
 import rest_framework_json_api.renderers
-from django_filters import rest_framework as filters
 from rest_framework_json_api.django_filters import DjangoFilterBackend
 from rest_framework_json_api.filters import OrderingFilter, QueryParameterValidationFilter
 from rest_framework_json_api.pagination import PageNumberPagination
diff --git a/rest_framework_json_api/django_filters/backends.py b/rest_framework_json_api/django_filters/backends.py
--- a/rest_framework_json_api/django_filters/backends.py
+++ b/rest_framework_json_api/django_filters/backends.py
@@ -1,10 +1,10 @@
 import re
 
+from django_filters import VERSION
+from django_filters.rest_framework import DjangoFilterBackend
 from rest_framework.exceptions import ValidationError
 from rest_framework.settings import api_settings
 
-from django_filters import VERSION
-from django_filters.rest_framework import DjangoFilterBackend
 from rest_framework_json_api.utils import format_value
 
 


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Don't output key for write only relations
If the `write_only` key is `True` on a relationship, its key is still included in the response body with an empty resource object (`{'data': null}`).

This was fixed in #230 for normal fields but not for relations.


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/renderers.py b/rest_framework_json_api/renderers.py
--- a/rest_framework_json_api/renderers.py
+++ b/rest_framework_json_api/renderers.py
@@ -99,6 +99,10 @@ def extract_relationships(cls, fields, resource, resource_instance):
             if field_name == api_settings.URL_FIELD_NAME:
                 continue
 
+            # don't output a key for write only fields
+            if fields[field_name].write_only:
+                continue
+
             # Skip fields without relations
             if not isinstance(
                 field, (relations.RelatedField, relations.ManyRelatedField, BaseSerializer)


Test patch:
diff --git a/example/tests/unit/test_renderers.py b/example/tests/unit/test_renderers.py
--- a/example/tests/unit/test_renderers.py
+++ b/example/tests/unit/test_renderers.py
@@ -46,7 +46,7 @@ class ReadOnlyDummyTestViewSet(views.ReadOnlyModelViewSet):
 
 
 def render_dummy_test_serialized_view(view_class):
-    serializer = DummyTestSerializer(instance=Entry())
+    serializer = view_class.serializer_class(instance=Entry())
     renderer = JSONRenderer()
     return renderer.render(
         serializer.data,
@@ -87,3 +87,33 @@ def test_render_format_keys(settings):
 
     result = json.loads(rendered.decode())
     assert result['data']['attributes']['json-field'] == {'json-key': 'JsonValue'}
+
+
+def test_writeonly_not_in_response(settings):
+    """Test that writeonly fields are not shown in list response"""
+
+    settings.JSON_API_FORMAT_FIELD_NAMES = 'dasherize'
+
+    class WriteonlyTestSerializer(serializers.ModelSerializer):
+        '''Serializer for testing the absence of write_only fields'''
+        comments = serializers.ResourceRelatedField(
+            many=True,
+            write_only=True,
+            queryset=Comment.objects.all()
+        )
+
+        rating = serializers.IntegerField(write_only=True)
+
+        class Meta:
+            model = Entry
+            fields = ('comments', 'rating')
+
+    class WriteOnlyDummyTestViewSet(views.ReadOnlyModelViewSet):
+        queryset = Entry.objects.all()
+        serializer_class = WriteonlyTestSerializer
+
+    rendered = render_dummy_test_serialized_view(WriteOnlyDummyTestViewSet)
+    result = json.loads(rendered.decode())
+
+    assert 'rating' not in result['data']['attributes']
+    assert 'relationships' not in result['data']
Repository: django-json-api/django-rest-framework-json-api

Issue:
@six gone missing with DRF 3.10.x
It looks like the upcoming DRF 3.10 release drops Py2 support and the `six` module. It used to import it here: https://github.com/encode/django-rest-framework/blob/3.9.x/rest_framework/serializers.py#L26 and it is gone in master now.

Apparently it is used only one place in DJA: https://github.com/django-json-api/django-rest-framework-json-api/blob/26e65a14b27c82b16cd393a3d5821a966464de51/rest_framework_json_api/serializers.py#L261

and must have been importing it from here: https://github.com/django-json-api/django-rest-framework-json-api/blob/26e65a14b27c82b16cd393a3d5821a966464de51/rest_framework_json_api/serializers.py#L5

"noqa" indeed!




Discussion:
@leo-naeka in case you want to fix this...
```
61406625 (leo-naeka 2017-06-05 22:23:17 +0200 261) @six.add_metaclass(PolymorphicSerializerMetaclass)
```

Resolving patch:
diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -1,4 +1,5 @@
 import inflection
+import six
 from django.db.models.query import QuerySet
 from django.utils.translation import ugettext_lazy as _
 from rest_framework.exceptions import ParseError


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Build docs error when creating api doc
Following error occurs when running `make html`
```
Running Sphinx v2.0.1
usage: sphinx-build [OPTIONS] -o <OUTPUT_PATH> <MODULE_PATH> [EXCLUDE_PATTERN, ...]
sphinx-build: error: unrecognized arguments: ../rest_framework_json_api
```

See 
https://readthedocs.org/projects/django-rest-framework-json-api/builds/9074255/

A regression since updated to Sphinx 2.0. Not so sure though why because when running sphinx-build directly on the console it works without any problems.


Discussion:
@n2ygk Do you have an idea what the issue could be?

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -28,7 +28,7 @@
 
 # Auto-generate API documentation.
 from sphinx.ext.apidoc import main
-main(['sphinx-apidoc', '-e',  '-T',  '-M',  '-f',  '-o', 'apidoc', '../rest_framework_json_api'])
+main(['-o', 'apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api'])
 
 # -- General configuration ------------------------------------------------
 


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Use "ObjectDoesNotExist" from model_class
Fixes #
```python

File "/home/anton/.virtualenvs/epantry/lib/python3.6/site-packages/rest_framework/serializers.py", line 748, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
File "/home/anton/.virtualenvs/epantry/lib/python3.6/site-packages/rest_framework/serializers.py", line 626, in run_validation
    value = self.to_internal_value(data)
File "/home/anton/.virtualenvs/epantry/lib/python3.6/site-packages/rest_framework/serializers.py", line 665, in to_internal_value
    validated = self.child.run_validation(item)
File "/home/anton/.virtualenvs/epantry/lib/python3.6/site-packages/rest_framework/fields.py", line 535, in run_validation
    value = self.to_internal_value(data)
File "/home/anton/projects/ePantry/epantry/django-rest-framework-json-api/rest_framework_json_api/serializers.py", line 49, in to_internal_value
    except ObjectDoesNotExist:
NameError: name 'ObjectDoesNotExist' is not defined
```
## Description of the Change

Looks like `ObjectDoesNotExist` is not imported in the module and it fails whenever `return self.model_class.objects.get(pk=pk)` raises an exception

## Checklist

- [x] PR only contains one change (considered splitting up PR)
- [x] unit-test added
- [ ] documentation updated
- [ ] `CHANGELOG.md` updated (only for user relevant changes)
- [ ] author name in `AUTHORS`



Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -1,4 +1,5 @@
 import inflection
+from django.core.exceptions import ObjectDoesNotExist
 from django.db.models.query import QuerySet
 from django.utils.translation import ugettext_lazy as _
 from rest_framework.exceptions import ParseError


Test patch:
diff --git a/example/tests/test_serializers.py b/example/tests/test_serializers.py
--- a/example/tests/test_serializers.py
+++ b/example/tests/test_serializers.py
@@ -119,6 +119,20 @@ def test_deserialize_primitive_data_blog(self):
         self.assertTrue(serializer.is_valid(), msg=serializer.errors)
         assert serializer.validated_data == self.blog
 
+    def test_deserialize_primitive_data_blog_with_unexisting_pk(self):
+        unexisting_pk = self.blog.id
+        self.blog.delete()
+        assert not Blog.objects.filter(id=unexisting_pk).exists()
+
+        initial_data = {
+            'type': format_resource_type('Blog'),
+            'id': str(unexisting_pk)
+        }
+        serializer = ResourceIdentifierObjectSerializer(data=initial_data, model_class=Blog)
+
+        self.assertFalse(serializer.is_valid())
+        self.assertEqual(serializer.errors[0].code, 'does_not_exist')
+
     def test_data_in_correct_format_when_instantiated_with_queryset(self):
         qs = Author.objects.all()
         serializer = ResourceIdentifierObjectSerializer(instance=qs, many=True)
Repository: django-json-api/django-rest-framework-json-api

Issue:
Use extra requires to seperate optional features django-filter and polymorphic
The optional features (Polymorphic and Django filter) should define their dependencies as extra.

Currently this is only done as test requires but actual users won't have enforced minimum requirements.

Once this is done a user can simply add following into their requirements to properly activate an optional feature:

```
djangorestframework-jsonapi[django-filter] == 2.8.0
```

see 
https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies 


Discussion:
@sliverc ~~should this be done using something similar to DRF's [compat.py](https://github.com/encode/django-rest-framework/blob/master/rest_framework/compat.py)~~ (never mind)
@sliverc I've been staring at this for a bit... One issue is that I want to have the following extra-requires but one of them has it's own Django version constraints:

`django-oauth-toolkit>=1.2.0` only when `django>=2`. If `django>=1.11,<2`, then `django-oauth-toolkit>=1.1,<1.2` -- but my `TokenMatchesOASRequirements` is only implemented in DOT 1.2, so DOT not even need for 1.1 (I suppose I could back port it...). You can see this in tox.ini/.travis.yml changes I've made in #689.

I'm not sure if setup.py's `extra_requires` can be customized based on Django version. Do you know if it can?
I don't think this is possible. However #689 will need some discussion also around the oauth feature.

This shouldn't affect implementing this issue for `django-filter` and `django-polymorphic` though. And I am sure for #689 we will find a suitable option. 



Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,6 +90,10 @@ def get_package_data(package):
         'djangorestframework>=3.10',
         'django>=1.11',
     ],
+    extras_require={
+        'django-polymorphic': ['django-polymorphic>=2.0'],
+        'django-filter': ['django-filter>=2.0']
+    },
     python_requires=">=3.5",
     zip_safe=False,
 )


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Tox using pytest-runner setup scripts leads to invalid deps
Currently tox uses pytest-runner setup script wrapper. This way tests are run differently when run locally as stated in README.md.

This may lead to different dependencies and errors as for example #634

Best to split up requirements as in [DRF](https://github.com/encode/django-rest-framework/tree/master/requirements) and remove setup pytest-runner script. Once this is done `test_requires` in setup.py would not be needed which remoes the duplication to requirements-development.txt


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -31,7 +31,7 @@
 django.setup()
 
 # Auto-generate API documentation.
-main(['-o', '_build/apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api'])
+main(['-o', 'apidoc', '-f', '-e', '-T', '-M', '../rest_framework_json_api'])
 
 # -- General configuration ------------------------------------------------
 


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Tag new version for Django 3.0/DRF 3.11/Python 3.8 support
Is there any chance we will see a new version in pip any time soon now that #752 is merged? Thanks!


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/__init__.py b/rest_framework_json_api/__init__.py
--- a/rest_framework_json_api/__init__.py
+++ b/rest_framework_json_api/__init__.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 __title__ = 'djangorestframework-jsonapi'
-__version__ = '3.0.0'
+__version__ = '3.1.0'
 __author__ = ''
 __license__ = 'BSD'
 __copyright__ = ''


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
django-polymorphic now does support Django>3.0
I don't use polymorphic but noticed that the docs build was failing with this traceback:
```
Traceback (most recent call last):
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/sphinx/config.py", line 319, in eval_config_file
    execfile_(filename, namespace)
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/sphinx/util/pycompat.py", line 88, in execfile_
    exec(code, _globals)
  File "/Users/alan/src/kezy182/docs/conf.py", line 31, in <module>
    django.setup()
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/Users/ac45/.pyenv/versions/3.6.10/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/polymorphic/models.py", line 17, in <module>
    from .base import PolymorphicModelBase
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/polymorphic/base.py", line 18, in <module>
    from .managers import PolymorphicManager
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/polymorphic/managers.py", line 10, in <module>
    from polymorphic.query import PolymorphicQuerySet
  File "/Users/alan/src/kezy182/.tox/docs/lib/python3.6/site-packages/polymorphic/query.py", line 11, in <module>
    from django.db.models import FieldDoesNotExist
ImportError: cannot import name 'FieldDoesNotExist'
```

I worked around this by forcing `Django>=2.2,<3.0` to get the docs built. PR coming shortly.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,8 +90,8 @@ def get_package_data(package):
     ],
     install_requires=[
         'inflection>=0.3.0',
-        'djangorestframework>=3.10',
-        'django>=1.11',
+        'djangorestframework>=3.10,<3.12',
+        'django>=1.11,<3.1',
     ],
     extras_require={
         'django-polymorphic': ['django-polymorphic>=2.0'],


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Tag new version to release in pip
Hi @sliverc, great work on DJA. May I know whether we can have a new release? I'm keen to use #781.

Thanks 😄


Discussion:
We are planning a release. There is a blocking issue though explained at https://github.com/django-json-api/django-rest-framework-json-api/pull/787#issuecomment-675384206 

Once we find an solution for this issue we will do another release.

Resolving patch:
diff --git a/rest_framework_json_api/__init__.py b/rest_framework_json_api/__init__.py
--- a/rest_framework_json_api/__init__.py
+++ b/rest_framework_json_api/__init__.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 __title__ = 'djangorestframework-jsonapi'
-__version__ = '3.1.0'
+__version__ = '3.2.0'
 __author__ = ''
 __license__ = 'BSD'
 __copyright__ = ''


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
document IncludedResourcesValidationMixin
split documentation improvements out of #416 for included resources.


Discussion:

Resolving patch:
diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py
--- a/rest_framework_json_api/serializers.py
+++ b/rest_framework_json_api/serializers.py
@@ -57,6 +57,12 @@ def to_internal_value(self, data):
 
 
 class SparseFieldsetsMixin(object):
+    """
+    A serializer mixin that adds support for sparse fieldsets through `fields` query parameter.
+
+    Specification: https://jsonapi.org/format/#fetching-sparse-fieldsets
+    """
+
     def __init__(self, *args, **kwargs):
         super(SparseFieldsetsMixin, self).__init__(*args, **kwargs)
         context = kwargs.get('context')
@@ -85,6 +91,13 @@ def __init__(self, *args, **kwargs):
 
 
 class IncludedResourcesValidationMixin(object):
+    """
+    A serializer mixin that adds validation of `include` query parameter to
+    support compound documents.
+
+    Specification: https://jsonapi.org/format/#document-compound-documents)
+    """
+
     def __init__(self, *args, **kwargs):
         context = kwargs.get('context')
         request = context.get('request') if context else None
@@ -147,6 +160,20 @@ class Serializer(
     IncludedResourcesValidationMixin, SparseFieldsetsMixin, Serializer,
     metaclass=SerializerMetaclass
 ):
+    """
+    A `Serializer` is a model-less serializer class with additional
+    support for json:api spec features.
+
+    As in json:api specification a type is always required you need to
+    make sure that you define `resource_name` in your `Meta` class
+    when deriving from this class.
+
+    Included Mixins:
+
+    * A mixin class to enable sparse fieldsets is included
+    * A mixin class to enable validation of included resources is included
+    """
+
     pass
 
 


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Drop end of life Django versions (2.1, 1.11)
This has been discussed but it is good to have its own single issue for dropping and adding features :smile: 

See https://www.djangoproject.com/download/ for release schedule.




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -91,7 +91,7 @@ def get_package_data(package):
     install_requires=[
         'inflection>=0.3.0',
         'djangorestframework>=3.10,<3.12',
-        'django>=1.11,<3.1',
+        'django>=2.2,<3.1',
     ],
     extras_require={
         'django-polymorphic': ['django-polymorphic>=2.0'],


Test patch:
Repository: django-json-api/django-rest-framework-json-api

Issue:
Add DRF 3.12 support
See https://www.django-rest-framework.org/community/3.12-announcement/


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -90,7 +90,7 @@ def get_package_data(package):
     ],
     install_requires=[
         'inflection>=0.3.0',
-        'djangorestframework>=3.10,<3.12',
+        'djangorestframework>=3.12,<3.13',
         'django>=2.2,<3.1',
     ],
     extras_require={


Test patch: