'Test that custom queryset has still precedence (#21405)'

def test_custom_queryset_still_wins(self):

    class SongAdmin(admin.ModelAdmin, ):
        def formfield_for_foreignkey(self, db_field, **kwargs):
            if (db_field.name == u'band'):
                kwargs[u'queryset'] = Band.objects.filter(rank__gt=2)
            return super(SongAdmin, self).formfield_for_foreignkey(db_field, **kwargs)
        def formfield_for_manytomany(self, db_field, **kwargs):
            if (db_field.name == u'other_interpreters'):
                kwargs[u'queryset'] = Band.objects.filter(rank__gt=2)
            return super(SongAdmin, self).formfield_for_foreignkey(db_field, **kwargs)
    class StaticOrderingBandAdmin(admin.ModelAdmin, ):
        ordering = (u'rank',)
    admin.site.unregister(Song)
    admin.site.register(Song, SongAdmin)
    admin.site.register(Band, StaticOrderingBandAdmin)
    self.check_ordering_of_field_choices([self.b2])
