-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Response format change from 3.2.x to 3.3.x #3644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You probably missed previous deprecation affecting the pagination. If your use case doesn't match the above cases feel free to reopen and if possible add a test case so we can figure the issue. |
Reopening to dig a bit deeper. @xordoquy prob correct re. related to deprecation there, but shouldn't be in a position where we've got an altered API response, rather than an error condition (eg hitting an assertion 'this no longer works') Probably worth a bit more info from @troygrosfield on most minimal way possible to replicate, so we can see if we need to be catching some particular case, and eg raising error XYZ style is no longer supported. |
I'll work on the testcase here in a bit, but you can plug any model into a ViewSet and have it do the same thing (alter the response format as mentioned above). @xordoquy, the deprecation link you provided didn't mention anything about altering response formats in any case which to me would warrant a major version change. I'll work on the test case but here was the code I was working with: from rest_framework.filters import DjangoFilterBackend
from rest_framework.filters import OrderingFilter
from rest_framework.viewsets import ReadOnlyModelViewSet
from my_models.models import MyModel
from .serializers import MyModelSerializer
class MyModelViewSet(ReadOnlyModelViewSet):
queryset = MyModel.objects.all()
serializer_class = MyModelSerializer
permission_classes = []
filter_backends = (OrderingFilter, DjangoFilterBackend)
filter_fields = ('some_field',)
ordering = ('-id',)
page_query_param = 'p' |
@troygrosfield What are your pagination settings for the example given? |
Makes sense to make it fail loud. |
The current settings are below.
I understand some of those pagination settings have change from the deprecation post you guys outlined which I'm yet to update. However, I also never received any deprecation messages in the console when running the application which I guess I would've expected similar to what django does. Example:
|
That was the issue was changing the global settings. However, that seems to be a major change as that will most certainly break pagination for all all existing code which will require all DRF consumers to make a change. A 4.0 release version may have been more appropriate. New global settings (for people that come across this in the future) # djangorestframework settings
REST_FRAMEWORK = {
# Use hyperlinked styles by default.
# Only used if the `serializer_class` attribute is not set on a view.
'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.HyperlinkedModelSerializer',
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'api.authentication.CustomSessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAdminUser',
),
'PAGE_SIZE': 25,
'PAGE_SIZE_QUERY_PARAM': 'ps',
'SEARCH_PARAM': 'q',
'MAX_PAGE_SIZE': 100
} Thanks for the quick response guys! |
Reopening, as should probably still be taking action here, eg.
|
👍 agreed. |
Furthermore, not convinced on first sight that |
Actually, paging page and page size aren't being honored now. Using the following url (with the settings listed above): I get the following response:
If I override the page size in the url, shouldn't that be honored? Also, Or am I required to override the |
Ignore that last comment. I was looking at count as the number of results returned and not as the total count. So that's correct. |
Is it okay if i work on this issue? |
@Cheglader I don't think anyone's working on this at the moment. |
+1 I cant even get it to return a dict. djangorestframework==3.3.1 settings
custom pagination
still results in
|
Also getting, when browsing the 'rest_framework.renderers.BrowsableAPIRenderer',
|
@rosscdh The discussion group is the best place to take usage questions. Thanks! |
@xordoquy Im not sure this is a usage problem. Followed docs and notes: http://www.django-rest-framework.org/topics/3.3-announcement/#deprecations no joy. Am a very long time user of DRF. Not a new project. |
Unless we have a minimal test case I'm going to consider it's a usage issue.
gives me:
Note it's the same with an explicit |
Raise error when setting a removed rest_framework setting for #3644
After upgrading DRF from 3.2.5 to 3.3.1 I noticed the api response format changed and no longer represents the format that's shown on the main page.
Api response with DRF 3.2.5 (expected response)
Api response with DRF 3.3.1 (only returns list/array)
There is only 1 object returned in the result set so no additional pages exist. However, this change breaks every api consuming caller since the response format has now changed.
The text was updated successfully, but these errors were encountered: