[PYTHON] Django "Query Set, Object has no attribute'foo'" solution

environment Python 3.5.0 Django 1.9.2

If you want to get the category of the specified article and use the method

views.py


def edit(request, article_id):
	category = Category.objects.filter(article=article_id)
	category_foo = category.foo()

filter

views.py


def edit(request, article_id):
	category = Category.objects.get(article=article_id)
	category_foo = category.foo()

Change to get.

Recommended Posts

Django "Query Set, Object has no attribute'foo'" solution
AttributeError:'NoneType' object has no attribute'loader'
Django Query Set Evaluation Timing Experiment
Blender has no object selection order
With xmpppy'_ssl._SSLSocket' object has no attribute'issuer'
When'DataFrame' object has no attribute'ix' appears in pandas
AttributeError: module ‘torch.utils’ has no attribute ‘data’ solution
Solution when module'XXX' has no attribute'XXX' in Python
AttributeError: I was addicted to'module' object has no attribute'MyTestCase'