【发布时间】:2017-09-28 03:55:25
【问题描述】:
customer = CustomerProfile.objects.get(pk=4)
ipdb> SimilarCustomerFinder(self, customer=customer, fields=self.fields)
*** TypeError: __init__() got multiple values for keyword argument 'customer'
在SimilarCustomerFinder 课上,我有
def __init__(self, customer, fields):
self._matches = {}
props = self.__class__.__dict__.keys()
self.customer = customer
self.fields = fields
self.checks = [k for k in props if k.startswith('check_')]
if customer:
self.user_id = customer.user.pk
else:
self.user_id = -1
for check in self.checks:
c = check.replace('+', '_')
getattr(self, c)()
我正在努力解决这个错误。我该如何解决?如果我删除customer=customer,我得到*** AttributeError: 'CustomerUpdateForm' object has no attribute 'user',为什么?
【问题讨论】:
-
这段代码没有意义。第一个 sn-p 中的
self是什么?
标签: python