Reputation: 907
I am working on a Django application and have defined the line below in my urls.py
path('organizations/', views.OrganizationListView().as_view(), name='organizations'),
When I run my server, I get the error below
lib\site-packages\django\utils\decorators.py", line 11, in __get__
raise AttributeError("This method is available only on the class, not on instances.")
AttributeError: This method is available only on the class, not on instances.
I understand that this must be because of the difference in calling a method on object vs class but not sure exactly what is causing it and how to resolve.
Upvotes: 5
Views: 3642
Reputation: 599490
You're instantiating the class here, which you shouldn't. It should be:
path('organizations/', views.OrganizationListView.as_view(), name='organizations'),
Upvotes: 15