Saturday, March 31, 2012

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

hello, thanks.

I wonder if it was caused by this error: ValueError: unknown locale: UTF-8 . It shows up but if I run the code again, it disappears..Otherwise, I have not made any mistakes and followed the tutorials ..

-Kisun
On Mar 31, 2012, at 11:38 PM, Sergiy Khohlov wrote:

> 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.
>

--
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