@python_2_unicode_compatible
class EmployerProfile(AbstractAddress):
customer = models.OneToOneField(
CustomerProfile, verbose_name=_('Customer'),
related_name='employerprofile')
company_name = models.CharField(_('Company name'),
max_length=50, blank=True, null=True)
phone = PhoneField(_('Phone'), max_length=50, blank=True, null=True)
phone_extension = models.CharField(_('Extension'), max_length=10,
blank=True, null=True)
job_title = models.CharField(_('Job title'), max_length=50, blank=True,
null=True)
date_hired = models.DateField(_('Date hired'), blank=True, null=True)
supervisor_name = models.CharField(_('Supervisor name'), max_length=50,
...
blank=True, null=True)
has_missing_fields = models.BooleanField(_('Has missing informations'),
default=True)
manual_validation = GenericRelation(ManualFieldValidation)
这是我想要使用元类
修改的函数def clean_fields(self):
if income_source != 'Employed':
to_empty = [
"company_name",
"job_title",
"date_hired",
"supervisor_name",
"phone",
"phone_extension",
"civic_number",
"street",
"address_line_2",
"city",
"state",
"zip_code",
...
]
for field_name in to_empty:
setattr(self, field_name, None)
super(EmployerProfile, self).save(*args, **kwargs)
任何人都可以告诉我为什么行super(EmployerProfile, self).save(*args, **kwargs)
有这种类型的错误?我花了很少时间弄清问题是什么,但没有成功。
答案 0 :(得分:0)
由于给出的原因,您收到错误:未在全局或本地范围中定义名称try n = do
(x,y) <- calc n
return (x+1, y+1)
try2 n = (x+1,y+1)
where
Just (x,y) = calc n
calc x
| x == 0 = Nothing
| otherwise = Just (x+1, 1)
main :: IO ()
main = print $ try 0
。不是kwargs。