我有一個用戶配置文件模型。我想要一個新的模型方法給我如何完成配置文件的分數。例如:Django配置文件顯示完成百分比
Name 10%
Mobile 50%
Gender 10%
Website 10%
Location 10%
birth_date 10%
含義,如果用戶已經填寫名和移動他們的個人資料將60%完成。
有人能讓我開始如何完成這樣的事情嗎?感謝:
我的模型:
class Profile(UserenaLanguageBaseProfile):
""" Default profile """
GENDER_CHOICES = (
(1, _('Male')),
(2, _('Female')),
)
user = models.OneToOneField(User,
unique=True,
verbose_name=_('user'),
related_name='profile')
gender = models.PositiveSmallIntegerField(_('gender'),
choices=GENDER_CHOICES,
blank=True,
null=True)
mobile = models.CharField(max_length=32, blank=True)
website = models.URLField(_('website'), blank=True,)
location = models.CharField(_('location'), max_length=255, blank=True)
birth_date = models.DateField(_('birth date'), blank=True, null=True)
你會做一個@property的東西嗎? – GrantU
好..沒必要,但肯定。你打算用它做任何事情嗎? – karthikr
可能有些時候我需要覆蓋一些數值,或者使用yes來做特殊的事情。 – GrantU