Spot on. Thanks Karen
On May 24, 11:08 am, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sat, May 23, 2009 at 9:57 PM, adelaide_mike
> <mike.ro...@internode.on.net>wrote:
>
>
>
>
>
> > First, please forgive my post to the Django developers group. I mis-
> > understood the terminology.
>
> > I am a total beginner in Django but have long experience with Omnis.
> > My data stores addresses in three tables named
> > Suburb, (columns are id, name)
> > Street, (columns are id, name, suburb_id)
> > Property (columns are id, number, street_id)
>
> > I have the Admin all working well (as per the Poll tutorial) but need
> > to extend it. I can "Add a property" and on that page I see a pick
> > list for the street name. Can I get that pick list to show the suburb
> > name also by somehow concatenating the street and suburb names
> > together?
>
> > In my models.py I have, for each class (using Street as an example):
> > def__unicode__(self)
> > return self.name
>
> > I have not found an exception-free way of changing the last line above
> > to involve the parent class. Any help would be greatly appreciated.
>
> Something like (for Street):
>
> def __unicode__(self):
> return u'%s, %s)' % (self.name, unicode(self.suburb))
>
> (assuming Suburb's __unicode__ returns its name) should do it. (And
> assuming suburb is not allowed to be null -- if it is then you'll need to
> test for a null suburb and fall back to just returning the street name and
> not attempting to access a non-existant related object.)
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
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
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---