I'd add to Michael's comment that if you're unhappy with this syntax (I personally find it a bit odd in some cases), you can customize exactly what word is used there in your model definition.
If you alter the choice model and add the "related_name" keyword to the foreign key definition, e.g.: class Choice(models.Model): ... poll = models.ForeignKey(Poll, related_name="choices") you can then do: >>> p.choices.create(...) On 23 June, 23:17, Michael Schade <mich...@mschade.me> wrote: > (Sorry in advance for the brevity and any typos, I am typing this from > my aging Windows Mobile). > > It's quite Django-specific actually. If you take a look > athttp://docs.djangoproject.com/en/dev/topics/db/queries/ it says, > "Django also creates API accessors for the "other" side of the > relationship -- the link from the related model to the model that > defines the relationship. For example, a Blog object b has access to a > list of all related Entry objects via the entry_set attribute: > b.entry_set.all()." > > Hope that clears things up. > > Michael Schade > Spearhead Development LLC > > On 6/23/10, Sector7B <joe.greenaw...@gmail.com> wrote: > > > > > > > Hi, > > In the tutorial 1. > > > It has this: > > # Give the Poll a couple of Choices. The create call constructs a new > > # choice object, does the INSERT statement, adds the choice to the set > > # of available choices and returns the new Choice object. Django > > creates > > # a set to hold the "other side" of a ForeignKey relation > > # (e.g. a poll's choices) which can be accessed via the API. > > > and gives these examples: > > # Create three choices. > >>>> p.choice_set.create(choice='Not much', votes=0) > > <Choice: Not much> > >>>> p.choice_set.create(choice='The sky', votes=0) > > <Choice: The sky> > >>>> c = p.choice_set.create(choice='Just hacking again', votes=0) > > > I understand what its doing, but I don't understand where the "_set" > > comes from or where its resolved to. > > Its probably more of a python thing than a django thing, but if > > someone could provide insight, it would be much appreciate. > > > Thanks, > > -j > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@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. > > -- > Sincerely, > Michael Schadewww.mschade.me- 815.514.1410 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.