I have a table in my model as follows:
---------------------------------------
class Schedule(meta.Model):
id = meta.AutoField(primary_key=True)
schedule = meta.CharField(maxlength=255, help_text='This takes a
Cron-style format (min hour dom mon dow)')
job = meta.ForeignKey(Job, db_column='jobid')
timevariance = meta.IntegerField('Max Duration', default=30,
help_text='The maximum amount of time, in minutes, that you expect the
job to take')
class META:
db_table = 'schedule'
admin = meta.Admin(
list_display = ('schedule', 'job', 'timevariance'),
)
---------------------------------------
For some reason, even though there are 11 records in the database for
this table the admin interface is only showing me one of them.
Underneath that one entry is message text saying "11 schedules", so I
know the DB API is finding them, I just don't know why it's not
displaying them.
Also, if I click on "Job" link to sort by that field, I get this:
---------------------------------------
There's been an error:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 64, in get_response
response = callback(request, **param_dict)
File "/usr/lib/python2.4/site-packages/django/views/admin/main.py",
line 134, in change_list
lookup_order_field = '%s.%s' % (f.rel.to.db_table,
f.rel.to.ordering[0])
IndexError: list index out of range
---------------------------------------
If I add in a custom __repr__ of """return "%s - %s - %s minutes" %
(self.schedule, self.get_job(), self.timevariance)""" and remove the
list_display variable it works fine, but there's no way of ordering,
and if I try adding ordering = ['job'] to the class META, I get the
following:
---------------------------------------
There's been an error:
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 64, in get_response
response = callback(request, **param_dict)
File "/usr/lib/python2.4/site-packages/django/views/admin/main.py",
line 134, in change_list
lookup_order_field = '%s.%s' % (f.rel.to.db_table,
f.rel.to.ordering[0])
IndexError: list index out of range
---------------------------------------
Any help appreciated,
Thanks, Tom
Let me know what other information you need to help troubleshoot it.
Thanks, Tom