[Fixed]-Add extra context variables into django oscar emails


Ended up making a custom management command to do it manually since the need to change the emails templates would be really rare.


From checking the source code, the ProfileUpdateView uses Django’s Class Based View FormView, which in turn implements the get_context_data method allowing the injection of extra data in the view.
You can simply create a view inehiriting ProfileUpdateView and override the get_context_data:

class MyProfileUpdateView(ProfileUpdateView):
    def get_context_data(self, **kwargs):
        context = super(MyProfileUpdateView, self).get_context_data(**kwargs)
        context['somevar'] = SomeQueryMaybe.objects.all()
        return context

Leave a comment