Saturday, March 31, 2012

Re: I don't get what Poll.objects.get(pk=1) does

look like all is correct.
it will be nice to separate a working with database and python
object. Using pk=1 you will get object with primary key equal 1.
Also yo will try to worki wit object as with list...

thanks,
serge

2012/3/31 excalibur1491 <excalibur1491@gmail.com>:
> Hi,
>
> I'm learning Django (I already know Python) and I'm following the
> tutorial: https://docs.djangoproject.com/en/1.3/intro/tutorial01/
> At the end of the tutorial there is a code where the programmer does:
> p = Poll.objects.get(pk=1) .
> I want to be sure if I understand it well.
> Poll.object.get(pk=1) is returning the poll which primary key is 1 in
> the DB, isn't it?
> This is stored in p, which is actually the poll which pk is 1, so it's
> itselft but with new class variables added (the other side of the
> Foreign Keys). Is it correct?
> This creates a new class variable called choice_set because Choise is
> an other-side foreign key of poll.
> This object (choise_set, of type RelatedManager) has a method create
> that adds things to the set.
>
>
> Did I understand it well??
>
> Thank you,
>
> (PS: sorry for my english )
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

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

No comments:

Post a Comment