Re: Django problem:AttributeError:Manage isn't accessible via Link instances

891 views
Skip to first unread message

Matt Woodward

unread,
Mar 21, 2013, 11:22:17 AM3/21/13
to django...@googlegroups.com
On Thursday, March 21, 2013 12:49:45 AM UTC-7, simon xue wrote:
When I read to page 31,"To get an object by ID,type the following:    >>>Link.object.get(id=1)

Unless this is just a typo that should be objects plural:
Link.objects.get(id=1)

Tom Evans

unread,
Mar 21, 2013, 12:04:05 PM3/21/13
to django...@googlegroups.com
On Thu, Mar 21, 2013 at 7:49 AM, simon xue <hellang...@gmail.com> wrote:
> Hi,When I read the book named "Learning Website Development With
> Django",step by step to doing the example,When I read to page 31,"To get an
> object by ID,type the following: >>>Link.object.get(id=1) " I got this
> error: "Traceback <most recent call last>:
> File "<console>",line 1,in<module>
> File"c:\python27\lib\site-packages\django\db\models\managers.py",line 232,in
> __get__
> raise AttributeError("manager isn't accessible via %s instances" %
> type.__name__)
> AttributeError: Manage isn't accessible via Link instances"
>
> How can I solve this problem?
>
> Thank U
>

You cannot access the 'objects' attribute through an instance of a
class, you must do it through the class method.

In addition to what Matt said ('objects', not 'object'), this could
happen if you typed exactly what you had said if you had redefined
what 'List' refers to. Eg:

>>> Link.objects.get(id=1)
<Link: a link>
>>> Link = Link.objects.get(id=1)
>>> Link.objects.get(id=1)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "…/django/db/models/manager.py", line 219, in __get__
raise AttributeError("Manager isn't accessible via %s instances" %
type.__name__)
AttributeError: Manager isn't accessible via Link instances


If you are still having problems, copy and past your entire console
session so that we can see what you have done!

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages