1
customer = CustomerProfile.objects.get(pk=4)
ipdb> SimilarCustomerFinder(self, customer=customer, fields=self.fields)
*** TypeError: __init__() got multiple values for keyword argument 'customer'
多個值在SimilarCustomerFinder
類,我有類型錯誤:__init __()得到了關鍵字參數 '客戶'
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'
,爲什麼?
此代碼沒有意義。第一個片段中的「self」是什麼? –