@pytest.mark.django_db
@pytest.mark.usefixtures('regular_user')
def test_picotable_correctly_sorts_translated_fields(rf, admin_user, regular_user):
 populate_if_required()
 columns = [Column('id', 'Id', filter_config=Filter(), display=instance_id), Column('name', 'Name', sort_field='translations__name', filter_config=TextFilter(filter_field='translations__name'))]
 pico = get_pico(rf, model=Product, columns=columns)
 sorted_products = pico.get_data({'perPage': 100, 'page': 1, 'sort': '+name'})
 sorted_names = [p['name'] for p in sorted_products['items']]
 assert (sorted_names == sorted(sorted_names))
 sorted_products = pico.get_data({'perPage': 100, 'page': 1, 'sort': '-name'})
 sorted_names = [p['name'] for p in sorted_products['items']]
 assert (sorted_names == sorted(sorted_names, reverse=True))

@ pytest . mark . django_db @ pytest . mark . usefixtures ( 'regular_user' ) def test_picotable_correctly_sorts_translated_fields ( rf , admin_user , regular_user ) : populate_if_required ( ) columns = [ Column ( 'id' , 'Id' , filter_config = Filter ( ) , display = instance_id ) , Column ( 'name' , 'Name' , sort_field = 'translations__name' , filter_config = TextFilter ( filter_field = 'translations__name' ) ) ] pico = get_pico ( rf , model = Product , columns = columns ) sorted_products = pico . get_data ( { 'perPage' : 100 , 'page' : 1 , 'sort' : '+name' } ) sorted_names = [ p [ 'name' ] for p in sorted_products [ 'items' ] ] assert ( sorted_names == sorted ( sorted_names ) ) sorted_products = pico . get_data ( { 'perPage' : 100 , 'page' : 1 , 'sort' : '-name' } ) sorted_names = [ p [ 'name' ] for p in sorted_products [ 'items' ] ] assert ( sorted_names == sorted ( sorted_names , reverse = True ) )
make sure that translated fields .