Well you'd want a relational table of author status', some thing like this:
class Journalist(models.Model): name = models.Charfield() class Article(models.Model): articles = models.Charfield class State(models.Model): state = models.CharField() class Article_relationship(models.Model): article = models.ForeignKey(Article) journalist = models.ForeignKey(Journalist) state = models.ForeignKey(State) You can define a ManyToMany and it will make relational tables for you in simple databases, but you can also define those tables explicitly like this and create a more custom database scheme. That's what i would do, however this could be set up in a few different ways. Joshua On Jun 26, 11:55 pm, bhunter <[EMAIL PROTECTED]> wrote: > Hi, sorry for what is probably a trivial question, but I'm new to > Django and a little fuzzy on databases in general, so I hope someone > here can help. Just to keep the motif, I'll frame my question in > terms of journalism. > > I'd like to set up a database with the following relationships: a > model of articles and a model of journalists. That's easy enough. > Because one article can have multiple journalists associated with it, > that's a ManyToMany relationship: > > class Journalist(models.Model): > pass > > class Article(models.Model): > journalists = models.ManyToManyField(Journalist) > > Simple, but that's not what I happen to want. What I really want in > my application is to know the *status* of a journalist with respect to > an article. That status could be, let's say, one of four things: > ["Unafilliated", "CurrentlyWriting", "DoneWriting", "Dead"]. > > Coming from a Python background, I might just call this a dictionary > of statuses, with Journalists being the keys, and each entry > containing one of four values: > > class Article(models.Model): > status = { "Bob Ryan" : "CurrentlyWriting", > "Rob Bradford" : "Unaffiliated", > "Peter Gammons" : "DoneWriting", > "Dan Shaughnessy" : "Dead"} > > Ok, Shaughnessy isn't dead, but if you lived in Boston, you'd > understand. Anyway, a dictionary is nice and all, but then the > information isn't in the database, and that's the whole point. > > Can anyone tell me what this relationship is called and how to do it > in Django? > > Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---