To display foreignkey data in my admin list view, I created a callable:
def next_date(self):
EvDateObj = EventDate.objects.filter(event__id__exact=self.id)
.exclude(event_date__lt=datetime.date.today())
.order_by('event_date')[:1]
return EvDateObj
This shows in the list view as:
[<EventDate: 25 September 2010>]
Which is the unicode string for the EventDate model (25 Sept 2010), with some django-generated object stuff around it: [< EventDate ______ >]
If I modify the callable return statement to try and just get the date itself:
return EvDateObj.event_date
or
return EvDateObj.event_date.strftime("%d %B %Y")
the admin list view simply shows:
(None)
Any thoughts? I am unsure how to proceed because I can get the desired object, but cannot access any of its properties without triggering the "(None)" result.