[Django]-"Cannot resolve keyword 'created' into field" on new DRF list view

2👍

Did you enable cursor pagination in your settings?

REST_FRAMEWORK = {
    ...
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.CursorPagination',
    ...
}

Be sure to read the docs on CursorPagination carefully:

Details and limitations

Proper use of cursor based pagination requires a little attention to detail. You’ll need to think about what ordering you want the scheme to be applied against. The default is to order by "-created". This assumes that there must be a ‘created’ timestamp field on the model instances, and will present a "timeline" style paginated view, with the most recently added items first.

In other words, you can’t have all three of these conditions:

  • Using cursor pagination
  • …without specifying an ordering
  • …on a model without a created field

Leave a comment