I am working on a website with Django.
I have created two models, one for photo and the other for a person.
class Photo(models.Model):
photo = models.ImageField(upload_to = 'toto')
description = models.CharField(_('Description'), max_length = 250)
people = models.ManyToManyField('Person', related_name = _('Person'))
def display_img(self):
return u'<img src="%s" /> - %s - %s' % (self.photo, self.description, self.people )
display_img.allow_tags = True
class Person(models.Model):
name = models.CharField(_('Name'), max_length = 50)
In my mind what I want is to be able to tag people on a photo.
My problem is that I am able to create a new photo with the admin, but when I want to modify/view it (http://127.0.0.1:8000/admin/module/photo/1/) I get this error:
Django Version: 1.4.1
Exception Type: TypeError
Exception Value:
filter() keywords must be strings
Exception Location: C:\Python26\Lib\site-packages\django\db\models\fields\related.py in get_query_set, line 543
and I am not able to understand it.
The full traceback would have been useful.
I expect the problem comes from the related_name
attribute in your people
field. You've marked this for translation, but that makes no sense: this is an attribute you use in your code, not something for public consumption. Take out the _()
call.