[Fixed]-How do I access the request object in a Django-CMS plugin?

24👍

The CMSPluginBase’s render method takes a context object. You should be able to access the request via that object if your view is using a RequestContext instance.

class MyCoolPlugin(CMSPluginBase):

    def render(self, context, instance, placeholder):

         #Do something with the request, like access the user
         current_user = context['request'].get('user', None)
         ...

Leave a comment