On Jul 14, 2009, at 9:23 AM, The Danny Bos wrote:

>
>
> So the Author and Illustrator tables would stay as is.
> How would the Interview table talk to both of those tables at once, to
> allow me to assign an interview to who I'm interviewing. Whether it's
> an Illustrator, Author or even down the track a Publisher.
>
> Like so?
>
> class Interview(models.Model):
>        body = models.TextField()
>        publication_date = models.DateField(auto_now=True)
>
>        interview_subject = ...
>
>        class Meta:
>                ordering = ['publication_date']
>
>


No, the other way around. The interview table wouldn't have anything  
in it to point to the illustrator or author. The Author and  
Illustrator models would each have a ManyToMany field defined to the  
Interview model. The "related_name" property of this field will give  
you an easy way, when using an Interview model, to pull its related  
Author or Illustrator objects. When you start with an Interview  
object, you'll need to do something like check to see if:   
len(this_interview.author.all()) > 0

Shawn

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to