I am trying to access parent class objects within the admin site with
the list display function.

The following are my models:
###
class Device(models.Model):
        make = models.CharField(maxlength=30)
        model = models.CharField(maxlength=50)
        partno = models.CharField('part number', maxlength=30)
        serial = models.CharField('serial number', maxlength=30,
primary_key=True)
        asset = models.CharField('asset tag', maxlength=30)
        recievedate = models.DateTimeField('date received')
        active = models.BooleanField()
        def __str__(self):
                return '%s (%s)' % (self.serial, self.asset)
        class Admin:
                list_display = ('make','model','serial','asset')

class Plan(models.Model):
        shortname = models.CharField(maxlength=30, primary_key=True)
        description = models.CharField(maxlength=100)
        active = models.BooleanField()
        device = models.ForeignKey(Device)
        def __str__(self):
                return '%s' % self.shortname
        class Admin:
                pass

class Task(models.Model):
        description = models.CharField(maxlength=30)
        frequency = models.IntegerField()
        active = models.BooleanField()
        plan = models.ForeignKey(Plan)
        def __str__(self):
                return '%s|%s' % (self.plan,self.description)
        class Admin:
                pass

class Log(models.Model):
        timestamp = models.DateTimeField('date completed')
        comments = models.TextField()
        active = models.BooleanField()
        task = models.ForeignKey(Task)
        def __str__(self):
                return '%s' % self.timestamp
        class Admin:
                list_display = ('timestamp','comments','task')
###

So, when I view Logs via the admin interface, I see the timestamp,
comments, and the return of __str__ for the parent task object.
However, I was really wanting to be able to view and sort based off of
some of the device fields (make, model, serial, etc).  Is there a way
to step up the ForeignKey bindings to higher level objects within the
Admin class?

Push come to shove, I could write a seperate functions to get the data
I am looking for, but then I would not be able to sort based on it.

I wasnt able to find a whole lot on how to do this in the DJango
documentation.  Although, I could be looking in the wrong places.  Any
help would be apprecaited.

Thanks!
 - DF


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to