Same thing, use CommodityLocatinoXref.objects.select_related(...).filter(...).order_by(...)


On 11/04/2022 20.03, divya murugulla wrote:

latamSupplyPoints = [ (e.globe_code_id, e.globe_code.plant_name) for e in CommodityLocationXref.objects.select_related('globe_code','cmdty_loc').filter(cmdty_loc_id__in=LatamLocationIds) ]

how to sort these values

On Monday, April 11, 2022 at 10:00:50 PM UTC+5:30 Antonis Christofides wrote:

    Hi,

    You need to replace

    queryset=GlobePlant.objects.all()

    with

    queryset=GlobePlant.objects.all().order_by(...)

    I can't tell you what arguments to give "order_by()" without seeing your
    GlobePlant model, but if you read Django's documentation for order_by you
    should be able to determine that.

    Regards,

    Antonis


    On 11/04/2022 18.47, divya murugulla wrote:

    Please help me sort the queryset by name alphabetical order.

     plant = forms.ModelChoiceField(label='Destinations
    Name',queryset=GlobePlant.objects.all(),empty_label='Select the
    Point',required=True)

    Thanks & Regards,
    Divya
-- You received this message because you are subscribed to the Google Groups
    "Django users" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to django-users...@googlegroups.com.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/56143c58-7525-4cab-959b-acf79b50a7dbn%40googlegroups.com
    
<https://groups.google.com/d/msgid/django-users/56143c58-7525-4cab-959b-acf79b50a7dbn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/743aaa4c-f709-424a-adfc-cd60b72f4644n%40googlegroups.com <https://groups.google.com/d/msgid/django-users/743aaa4c-f709-424a-adfc-cd60b72f4644n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4c935aa8-45dc-1d2e-c333-72b6c1540af3%40antonischristofides.com.

Reply via email to