Added the get_multi_language_attr() function to the Mia core application, to deal with the multi-lingual attributes, and applied it in the data models.
This commit is contained in:
@ -21,6 +21,8 @@
|
||||
|
||||
from django.db import models
|
||||
|
||||
from mia_core.utils import get_multi_language_attr
|
||||
|
||||
|
||||
class Country(models.Model):
|
||||
"""A country."""
|
||||
@ -46,6 +48,18 @@ class Country(models.Model):
|
||||
"""Returns the string representation of this country."""
|
||||
return self.code.__str__() + " " + self.name_zhtw.__str__()
|
||||
|
||||
_title = None
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
if self._title is None:
|
||||
self._title = get_multi_language_attr(self, "title")
|
||||
return self._title
|
||||
|
||||
@title.setter
|
||||
def title(self, value):
|
||||
self._title = value
|
||||
|
||||
class Meta:
|
||||
db_table = "countries"
|
||||
ordering = ["code"]
|
||||
|
Reference in New Issue
Block a user