Hey Victor,
I do the following to get data out of a related table/model:
Of course you could access your other model via __unicode__...
Or, simply write a function for your model and use a callback in your list_display:
Here an easy "quick and dirty" example:
class othermodel(models.Model)
importantfield=models.CharField(....)
class mymodel(models.Model)
value = models.CharField(....)
FK_othermodel= models.Foreignkey(othermodel)
def get_importantfield(self):
return self.FK_othermodel.importantfield
In your admin.py call
MymodelAdmin(admin.ModelAdmin)
list_display=['get_importantfield']
Hope it helps!
Mathieu
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment