2

I'm trying to add the django-voting app to my project. I don't know how to use it in my templates, so I'm adding a new template tags for voting up or down when an user click in buttons. I don't know if there's a well form to do it.

My problem is with these kind of line in the template tag:

obj = Place.objects.filter(id=object_id)
Vote.objects.record_vote(obj, self.user, +1)

django print:

Caught AttributeError while rendering: 'Place' object has no attribute '_meta'

How I can add the attribute _meta my object 'Place'?

beni
  • 3,019
  • 5
  • 35
  • 55

1 Answers1

10

The problem is that obj here is not actually an object, but a queryset with one element. You should use get instead of filter, as get actually returns a model instance.

obj = Place.objects.get(id=object_id)
Ismail Badawi
  • 36,054
  • 7
  • 85
  • 97