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に追加するのは難しいです。
[OK]私は私の質問で素朴だった...ありがとう! @DanielRoseman関数ベースのビューに基づいて 'context'を使用していたたびに、context_dataはクラスベースのビューと同じように動作します。 – Deadpool