jrief/django-admin-sortable2

Exception Value: Expression contains mixed types: TextField, IntegerField. You must set output_field.

jedie opened this issue · 3 comments

jedie commented

I get this error here:
grafik

It's here:

def get_max_order(self, request, obj=None):
return self.model.objects.aggregate(
max_order=Coalesce(Max(self.default_order_field), 0)
)['max_order']

I just add a poor work-a-round:

    def get_max_order(self, request, obj=None):
        return 0
jrief commented

Does this mean that method get_max_order returns a string rather than a number?

What's the field type of the field you're using for ordering? Please show me your model.

jrief commented

well, you're using a TextField as ordering variable. For obvious reasons this can't work and should have been discovered by yourself in the first place.