سؤال

I have a django-table2 where each row contains a foreign-key to a User object. When I click on the sort arrow for the User name it sorts by (I presume) the key of the User instead of the name. I can't find anything in the docs on how to fix this.

Python 2.7, Django 1.5.1, django-tables2 0.14.0

هل كانت مفيدة؟

المحلول

I swear I looked through the docs repeatedly. Not sure how I missed this.

http://django-tables2.readthedocs.org/en/latest/#specifying-alternative-ordering-for-a-column

Owner = tables.Column(order_by=("Owner.Full_Name"))

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top