[Django]-Django. Pass variable from view to template

3👍

Read How to use get_context_data in django
and
https://docs.djangoproject.com/en/1.9/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_context_data

Here is example of how you can do this

class CausesView(AjaxFormView):
    ...
    def get_context_data(self, **kwargs):
        context_data = super(CausesView, self).get_context_data(**kwargs)
        context_data['appuser'] = self.appuser
        return context_data

Leave a comment