클래스 기반 뷰를 사용하여 여러 객체를 렌더링하려고하지만 오류가 발생합니다. 여기 클래스 기반 뷰를 사용하여 여러 객체를 렌더링하는 방법
내 코드입니다 :class AssociatedList(WizardRequiredMixin, TemplateView):
template_name = "profile/associated_accounts.html"
def get_context_data(self, **kwargs):
context = super(AssociatedList, self).get_context_data(**context)
all_envelopes = Envelope.objects.filter(
user=request.user).exclude_unallocate()
free_limit = account_limit(request, 15, all_envelopes)
facebook = FacebookProfile.user_profiles(request.user)
google = GoogleProfile.user_profiles(request.user)
twitter = TwitterProfile.user_profiles(request.user)
context.update = ({
'facebook': facebook,
'google': google,
'twitter': twitter,
'free_limit': free_limit,
})
return context
오류 : 난 항상 상황에 맞는 함수의 시작 부분에 super
를 호출 한 후 추가하여 get_context_data
를 오버라이드 (override) 한
local variable 'context' referenced before assignment
무엇이 오류입니까? – Ngenator
@Ngenator 오류를 게시합니다 – catherine
Ngenator가 내 대답에 대한 의견에서 지적했듯이 '컨텍스트'를 정의하는 문에 '컨텍스트'에 대한 참조가 포함되었습니다. 그것은 내 부분에 복사 및 붙여 넣기 오류가 발생했습니다. 내 대답을 업데이 트했습니다, 그냥 '** contexts'를 '* args, ** kwargs'로 바꾸십시오. 함수의 첫 번째 줄에. –