django admin app error (Model with property field): global name 'full_name' is not defined

Posted by rxin on Stack Overflow See other posts from Stack Overflow or by rxin
Published on 2010-05-09T00:06:46Z Indexed on 2010/05/09 0:18 UTC
Read the original article Hit count: 377

This is my model:

class Author(models.Model):

    first_name = models.CharField(max_length=200)
    last_name = models.CharField(max_length=200)
    middle_name = models.CharField(max_length=200, blank=True)

    def __unicode__(self):
        return full_name

    def _get_full_name(self):
        "Returns the person's full name."
        if self.middle_name == '':
            return "%s %s" % (self.first_name, self.last_name)
        else:
            return "%s %s %s" % (self.first_name, self.middle_name, self.last_name)
    full_name = property(_get_full_name)

Everything is fine except when I go into admin interface, I see

TemplateSyntaxError at /bibbase2/admin/bibbase2/author/ Caught an exception while rendering: global name 'full_name' is not defined

It seems like the built-in admin app doesn't work with a property field. Is there something wrong with my code?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-admin