1 defRender (Request, *args, * *Kwargs):2 """3 Returns a httpresponse whose content is filled with the result of Calling| | The contents of the returned HttpResponse are filled with the result of the call4 django.template.loader.render_to_string () with the passed arguments.5 Uses a requestcontext by default. Use RequestContext by default. 6 """7Httpresponse_kwargs = {8 'Content_Type': Kwargs.pop ('Content_Type', None),9 'Status': Kwargs.pop ('Status', None),Ten } One
* *Kwargs The usage is that the input parameter becomes a dictionary
A if 'context_instance' inchKwargs: -Context_instance = Kwargs.pop ('context_instance') - ifKwargs.get ('Current_app', None): the RaiseValueError ('If You provide a context_instance you must' - 'set its current_app before calling render ()') - Else: -Current_app = Kwargs.pop ('Current_app', None) +Context_instance = RequestContext (Request, current_app=Current_app) - +kwargs['context_instance'] =context_instance A at returnHttpResponse (loader.render_to_string (*args, * *Kwargs), -**httpresponse_kwargs)
From django.shotcuts Import Render
1.*args: Multiple parameters can be entered
My. HTML Blog parameters are all part of the args
(2) in the dictionary, in and Has_key usage is the same, but recommended in, Python3 has deleted Has_key
GCA Line 12th
(3) The Pop method of the dictionary: pop[' key ' removes the key and the value of the key; and takes him out.
GCA Line 8th, line 13th
(4) Usage of raise
A =10if A: raise valueerror ('a = = ten')
Django Source Analysis--shotcuts