(django tables) Table not sortable

21 views
Skip to first unread message

Martin

unread,
Apr 29, 2011, 7:36:03 AM4/29/11
to Django Apps
Hello,

I just switched from the 0.3 to the 0.4 version of django tables.
Unfortunately my table is not sortable anymore, even though the column
header are clickable.

I registered django_tables in the INSTALLED_APPS, used my table
subclass, passed the data in my view and used

{% load django_tables %}
{% render_table table %}

in my html template. The table is visible but not sortable anymore.

Any suggestions how to solve this issue? Anything I forgot?

Thank you for your help.

Martin

unread,
May 6, 2011, 10:05:52 AM5/6/11
to Django Apps
Some more information: I am using Python 2.6.6 with Ubuntu 10.10. The
code I am using is the following:

class patient_table(tables.Table):
check = tables.columns.CheckBoxColumn()
patient_name = tables.Column(accessor='study_fk.patient_fk',
verbose_name='Name', sortable=True)
patient_sex =
tables.Column(accessor='study_fk.patient_fk.patients_sex',
verbose_name='Sex')
patient_birthdate =
tables.Column(accessor='study_fk.patient_fk.patients_birthdate',
verbose_name='Date of birth')
patient_age =
tables.Column(accessor='study_fk.patient_fk.get_age',
verbose_name='Age')
#study_date = tables.Column(accessor='study_fk.get_datetime')
modality = tables.Column(accessor='station_fk.modality')
station = tables.Column(accessor='station_fk.station_name')
description =
tables.Column(accessor='study_fk.requested_procedure_fk')
scheduled_procedure_step_status =
tables.Column(verbose_name='Status')
priority =
tables.Column(accessor='study_fk.requested_procedure_fk.requested_procedure_priority')
ref_physician =
tables.Column(accessor='study_fk.imaging_service_request_fk.physician_fk',
verbose_name='Referring physician')
per_physician = tables.Column(accessor='physician_fk',
verbose_name='Performing physician')

class Meta:
attrs = {'class': 'paleblue'}

Worked with 0.3(with the different notation), but now nothing happens.
The <a href> are always empty. I remember that there was the link in
it. Help is really appreciated.

Martin

unread,
May 11, 2011, 5:12:28 AM5/11/11
to Django Apps
Solution:

First of all we have to modify the settings.py and add the following:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request", # important one
)

The table needs to be created the following way:
table = patient_table(patients, order_by=request.GET.get('sort'))

Now everything works fine :)

On May 6, 4:05 pm, Martin <sayate...@googlemail.com> wrote:
> Some more information: I am using Python 2.6.6 with Ubuntu 10.10. The
> code I am using is the following:
>
> class patient_table(tables.Table):
>     check = tables.columns.CheckBoxColumn()
>     patient_name = tables.Column(accessor='study_fk.patient_fk',
> verbose_name='Name', sortable=True)
>     patient_sex =
> tables.Column(accessor='study_fk.patient_fk.patients_sex',
> verbose_name='Sex')
>     patient_birthdate =
> tables.Column(accessor='study_fk.patient_fk.patients_birthdate',
> verbose_name='Date of birth')
>     patient_age =
> tables.Column(accessor='study_fk.patient_fk.get_age',
> verbose_name='Age')
>     #study_date = tables.Column(accessor='study_fk.get_datetime')
>     modality = tables.Column(accessor='station_fk.modality')
>     station = tables.Column(accessor='station_fk.station_name')
>     description =
> tables.Column(accessor='study_fk.requested_procedure_fk')
>     scheduled_procedure_step_status =
> tables.Column(verbose_name='Status')
>     priority =
> tables.Column(accessor='study_fk.requested_procedure_fk.requested_procedure _priority')
Reply all
Reply to author
Forward
0 new messages