Question: I am using `Flask` and `SQLAlchemy`. I have a `Person` model and I want an attribute which returns the `Person`'s full name (first + last).

I tried using `@declared_attr`, but it outputs:

```
"person.first_name || :param_1 || person.last_name"

```

Here is my code:

```py
class Person(Base):
    __tablename__ = 'person'

    id = Column(Integer, primary_key = True)
    type = Column(String(50))
    first_name = Column(String(120), index = True)
    last_name = Column(String(120), index = True)

    @declared_attr
    def name(cls):
        "Returns Person's full name."
        return cls.first_name + ' ' + cls.last_name

```

Answer: 
Use the [hybrid](http://sqlalchemy.readthedocs.org/en/rel_0_9/orm/extensions/hybrid.html) extension:

```
from sqlalchemy.ext.hybrid import hybrid_property

class Person(Base):
    # ...
    @hybrid_property
    def name(self):
        return '{0} {1}'.format(self.first_name, self.last_name)

    @name.setter
    def name(self, value):
        self.first_name, self.last_name = value.split(' ', 1)

    @name.expression
    def name(cls):
        return db.func.concat(cls.first_name, ' ', cls.last_name)

```
@davidism suggested using hybrid extension, whilst I say, why not use SQLAlchemy's [`column_property` function](https://docs.sqlalchemy.org/en/latest/orm/mapping_columns.html#using-column-property-for-column-level-options)?

Example:

```
class User(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    firstname = Column(String(50))
    lastname = Column(String(50))
    fullname = column_property(firstname + " " + lastname)

```