W dniu poniedziałek, 25 czerwca 2012 18:54:48 UTC+2 użytkownik Kurtis 
napisał:
>
> Actually, I'm pretty confused about this part :) A ForeignKey is used to 
> relate to another Model -- not just a Model Field -- in Django's ORM.
>
> So for example, if you have a Team Model and a Player Model, you'd want to 
> include "team = models.ForeignKey(Team)" in your Player Model. If you want 
> to back-reference this from your Team, this is also possible (just look 
> through the docs). You don't need to declare the ForeignKey relationship 
> twice. Finally, when you want a specific field from the other Model (for 
> example, maybe a team's name) then you'd just query accordingly: 
> my_player.team.name
>

Let me follow up on this. Say I want to add list of all Teams my Players 
played for. What you're saying is that I don't have to add ForeignKey to 
Team and just use team_name field from Team model? Will it work?

This relations stuff is confusing :P.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/5g6k_XxiglQJ.
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