can't get sorting working for a django-tables2 table.
class MyModel(models.Model):
pid = models.AutoField('id',primary_key = True)
name = models.CharField(max_length = 255,
help_text='The name')
def show_mymodels(request):
""" the view """
table = MyModelTable(MyModel.objects.all())
return render(request,'mymodel.html',{'table':table})
class MyModelTable(tables.Table):
class Meta:
model = MyModel
orderable = True
And mymodel.html looks as follows:
{% load render_table from django_tables2 %}
{% render_table table %}
This renders the table correct but nothing happens when clicking the columns in the browser. Other then the urld change http://127.0.0.1:8000/show_mymodel
--> http://127.0.0.1:8000/show_mymodel?sort=name
What is it that I'm doing wrong?