netbox/netbox/users/migrations/0010_add_token_meta_ordering.py
Jason Novinger c736ce3179
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
Fixes #18900: raise QuerySetNotOrdered exception when trying to paginate unordered API querysets (#19943)
* Fixes #18900: introduce/raise QuerySetNotOrdered exception

Defines a new exception, `QuerySetNotOrdered`, and raises it in
`OptionalLimitOffsetPagination.paginate_queryset` in the right
conditions:
- the iterable to be paginated is a QuerySet isinstance
- the `queryset.ordered` flag is not truthy

* Don't try to reapply ordering if ordering is already present

* Add ordering for failing tagged-objects list API endpoint

I chose to implement this here for TaggedItemViewSet, rather than on the
model, because any meaningful ordering is going to be done on the
related Tag instance and I didn't want to introduce potential, not well
understood side-effects by applying a model-wide ordering via a related
model field.

* Add default Token ordering behavior

* Adds basic tests for raising QuerySetNotOrdered

* Note why ordering is not applied in TaggedItem.Meta
2025-07-29 11:49:36 -05:00

18 lines
347 B
Python

# Generated by Django 5.2.4 on 2025-07-23 17:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0009_update_group_perms'),
]
operations = [
migrations.AlterModelOptions(
name='token',
options={'ordering': ('-created',)},
),
]