Assuming the list of IDs isn’t too large, you could convert the QS to a list and sort it in Python:
album_list = list(albums)
album_list.sort(key=lambda album: album_ids.index(album.id))
More Related Contents:
- How can I combine two or more querysets in a Django view?
- How do I do an OR filter in a Django query?
- How to filter empty or NULL names in a QuerySet?
- Custom QuerySet and Manager without breaking DRY?
- Why does django’s prefetch_related() only work with all() and not filter()?
- Select DISTINCT individual columns in django?
- _set in Django for a queryset
- Raw SQL queries in Django views
- How to limit queryset/the records to view in Django admin site?
- Django: implementing JOIN using Django ORM?
- Django – filtering on foreign key properties
- How to create a Django queryset filter comparing two date fields in the same model
- Django Queryset with filtering on reverse foreign key
- How to dynamically provide lookup field name in Django query? [duplicate]
- Django lazy QuerySet and pagination
- Django: ManyToMany filter matching on ALL items in a list
- Django query datetime for objects older than 5 hours
- Django, query filtering from model method
- Django: Does prefetch_related() follow reverse relationship lookup?
- django most efficient way to count same field values in a query
- Django Order By Date, but have “None” at end?
- Django query case-insensitive list match
- Django queryset get exact manytomany lookup [duplicate]
- how to write a query to get find value in a json field in django
- What’s the difference between django OneToOneField and ForeignKey?
- How do I do a not equal in Django queryset filtering?
- Django ModelChoiceField: filtering query set and setting default value as an object
- Django ManyToMany model validation
- Multiple images per Model
- Django’s forms.Form vs forms.ModelForm