Combine Q objects in Django and limit one of them -


i want combine these 2 queries in 1 music object name xyz , top 3 objects genre 10, ordered artist:

1. music.objects.filter(name='xyz', genre=10)  2. music.objects.filter(genre=10).order_by('artist')[:3] 

i can use q objects don't know how order & filter 3rd q object below:

music.objects.filter( (q(name='xyz') & q(genre=10)) | q(genre=10) ) 

maybe try this?

music.objects.filter( (q(name='xyz') & q(genre=10)) | q(genre=10) ).order_by('artist')[:3] 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -