Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 4th, 2013  |  syntax: Python  |  size: 0.68 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #teams/models.py
  2. class Team(models.Model):
  3.         user = models.ForeignKey(User)
  4.  
  5. class Coordinator(models.Model):
  6.         user = models.ForeignKey(User)
  7.  
  8. class Wishlist(models.Model):
  9.         team = models.ForeignKey(Team)
  10.         coordinator = models.ForeignKey(Coordinator)
  11. #sybcdb creates a new table called teams_wishlist with the fields:
  12. #         id, team_id, coordinator_id, etc (extra wishlist related fields).
  13.  
  14. #in the shell I can't get to the wishlist through the Team object...
  15. #team.wishlist says 'Team' object has no attribute 'wishlist'
  16. #however:
  17. wishlists = Wishlist.objects.all()
  18. for w in wishlists:
  19.     print w.coordinator
  20.     print w.team
  21. #returns a list of the teams and coordinators.
clone this paste RAW Paste Data