Django: what is the difference between using request and context as argument -



Django: what is the difference between using request and context as argument -

i defining function in context_processor pass value settings utilize in templates. right way, , more importantly difference?

def baseurl(request): homecoming {'base_url': settings.base_url}

or

def baseurl(context): homecoming {'base_url': settings.base_url}

i have used first, have run few examples of second

you free phone call argument whatever request mutual or clear. django docs: https://docs.djangoproject.com/en/1.4/ref/templates/api/#writing-your-own-context-processors

a context processor has simple interface: it's python function takes 1 argument, httprequest object, , returns dictionary gets added template context.

while there nil stopping naming argument context misleading since passed httprequest object.

django

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -