You'd almost think they were handing out prizes for being quickest on  
the draw :)


On Jun 27, 2008, at 12:18 PM, joshuajonah wrote:

>
> And this is why the Django community rocks, two examples and a full
> explaination with a link in less than 10 minutes, GW guys
>
> 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
-~----------~----~----~----~------~----~------~--~---


Reply via email to