I'm stuck at what I think should have been one of the easiest steps of
building my magazines website: the models. :(
I really feel stupid for that, so please tell me the right way to do
this.

This is what I have: Magazines, with many Issues each, and articles,
which belong to only one Magazine, and therefore should only be allowed
to belong to the chosen Magazine's Issues.

myproj/myapp/models.py:

class Magazine(models.Model):
   ...
   name = models.CharField(...)

class Issue(models.Model):
   ...
   magazine = models.ForeignKey(Magazine)
   ...

class Article(models.Model):
   ...
   magazine = models.ForeignKey(Magazine)
   # Now I want to force the displaying of only the Issues that have
   # this same Magazine as their ForeignKey relation.
   # This is how I'm trying to do this:
   issue = models.ForeignKey(Issue,
limit_choices_to{'magazine__id__eq': magazine.id})

Django tells me that ForeignKey fields have no id attribute. Ok, I knew
that already, but there's *got* to be some way of limiting the choice
of issues to the ones that belong to the same Magazine the user chose.

So, my question here would be:
How can I access the attributes of a ForeignKey "target" when building
my model?

If this is not possible in the model definition steps, then how do I do
this limiting in the Admin page?

Any hint would be great.


--~--~---------~--~----~------------~-------~--~----~
 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to