I just saw the source of all my problems.
This is the code for the Article class:
class Article(models.Model):
"""This class defines an Article, with links to:
- a Magazine,
- a Section (which depends on the Magazine), and
- an Issue (which also depends on the Magazine)"""
def
Sorry, I forgot to actually *ask* the question. :)
I'm able to get a list of Sections related to 'Linux Magazine', for
example, with:
validsections = magazine.section_set.all()
This returns this list:
[, ] # (so far I've created only
these 2 sections)
Is there a method to restrict the
It did help. Thank you very much.
But the situation has changed already. :\
I'd like the Admin pages to show me only the Sections and Issues that
make sense for the Magazine I choose from the selectbox.
So, this is how my model is (sort of):
I have a Magazine class, an Issue class and a
Suppose that you have a Section model that has a foreign key to
Magazine, and the field in the Section model is called magazine. You
can then do something like this once you get the section:
s = Section.objects.select_related.get()
s.magazine.id will return the id of the magazine, if it has
I'm now building an online magazine website. Each magazine has the same
set of sections. And every article belongs to one and only one section.
So, the Article class has a ForeignKey(Section) line.
So far, so good (I guess). :)
But there are actually 2 magazines, each with its own group of
5 matches
Mail list logo