0
我有一个关于CBV Django进程和get_context_data()
的问题。用get_context_data提取多个变量Django
我想得到一些不同的变量,我不克服用我的功能做到这一点。
这是函数:
class IdentitySocietePDFCreatingView(LoginRequiredMixin, TemplateView) :
template_name = 'Identity_Societe_PDF.html'
model = Societe
def get_context_data(self, **kwargs) :
SID = Logger.login(lib.Global_variables.GED_LOG_USER, lib.Global_variables.GED_LOG_MDP)
context_data = super(IdentitySocietePDFCreatingView, self).get_context_data(**kwargs)
id = self.kwargs['id']
societe = get_object_or_404(Societe, pk=id)
obj = Societe.objects.filter (Nom=societe.Nom, SIRET=societe.SIRET, SIREN=societe.SIREN, Ville=societe.Ville)
if obj:
sc_obj = obj[0]
''' Rest of my script ''''
''' I have a variable named folderID which must be in my template ''''
context_data['queryset'] = obj
return context_data
我的问题是:
如何,我可以添加内部context_data
folderID
变量?我必须在我的模板obj
和folderID
中显示,但我没有克服在context_data中添加这两个变量。
好的我对我的问题很天真......谢谢! @DanielRoseman我一直使用基于基于函数的视图的'context',context_data和基于Class的视图一样。 – Deadpool