mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 21:38:48 +00:00
Annotate BuildList queryset with integer cast of the reference
This commit is contained in:
parent
aa7eb3a6d0
commit
0cdc82a4b3
@ -10,7 +10,8 @@ from django.core.exceptions import ValidationError as DjangoValidationError
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from django.db.models import Case, When, Value
|
from django.db.models import Case, When, Value
|
||||||
from django.db.models import BooleanField
|
from django.db.models import BooleanField, IntegerField
|
||||||
|
from django.db.models.functions import Cast
|
||||||
|
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from rest_framework.serializers import ValidationError
|
from rest_framework.serializers import ValidationError
|
||||||
@ -71,6 +72,11 @@ class BuildSerializer(InvenTreeModelSerializer):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Annotate with a "integer" version of the reference field, to be used for natural sorting
|
||||||
|
queryset = queryset.annotate(
|
||||||
|
integer_ref=Cast('reference', output_field=IntegerField())
|
||||||
|
)
|
||||||
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user