"relative" limit_choices_to

69 views
Skip to first unread message

zeu...@sopinspace.com

unread,
Aug 10, 2006, 3:37:51 AM8/10/06
to django-d...@googlegroups.com, django...@googlegroups.com
Hi all,

I saw many posts on this list on the dynamic limit_choices_to but I think my
question is a little bit different, but very common as well.

Here is a very simple example. I'd like to filter the streets in the
DrugStore edit page so that only the streets in the selected city appear, the
clumsy 'self'.city.id is here to illustrate that ... (it sounds to me like
the 'self' keyword used for recursive model linkage)

class City(models.Model):
pass

class Street(models.Model):
city = models.ForeignKey(City)

class DrugStore(models.Model):
city = models.ForeignKey(City)
street = models.ForeignKey(City, limit_choices_to =
{id_exact : 'self'.city.id})

Basically, my question is : is there a way to do that ("'self'.city.id") ? Can
you give me hints about how to code it if you have ideas and you think it
makes sense.

Cheers,

Z.

Reply all
Reply to author
Forward
0 new messages