You're getting a QuerySet back from filter, so you'll need to index
the result, i.e. c[0].

On Aug 31, 5:26 am, Artemis Fowl <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I was starting out to learn Django and was trying the tutorial
> presented in the website. In the part when the shell is used to create
> Poll and Choice objects, it is mentioned that Choice objects have
> access to Poll and Poll objects have access to Choice. The tutorial
> uses this example
>
> |-----------------------------------------------------------------------------------------------------|
> |  >>> c = p.choice_set.create(choice='Just hacking again', votes=0)
> |
> |-----------------------------------------------------------------------------------------------------|
>
> Then, it queries the object 'c' to get the poll it is associated with.
>
> |-----------------------------------------------------------------------------------------------------|
> |  # Choice objects have API access to their related Poll
> objects.         |
> |  >>>
> c.poll
> |
> |  <Poll: What's up?
>
> |
> |-----------------------------------------------------------------------------------------------------|
>
> But if I try it in another way, I get an error. Please help!
>
> |------------------------------------------------------------------------------------------------------|
> |  >>> c =
> Choice.objects.filter(choice__startswith='Just')                    |
> |  >>>
> c.poll
> |
> |  Traceback (most recent call
> last):                                                   |
> |    File "<console>", line 1, in
> <module>                                            |
> |  AttributeError: 'QuerySet' object has no attribute
> 'poll'                       |
> |-----------------------------------------------------------------------------------------------------|
>
> Many Thanks,
> Artemis.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to