Locals () returns a dictionary containing all the variables and their values in the current scope. Therefore, you can rewrite views to defcurrent_datetime (request): current_datetime.datetime.now()returnrender_to_response(current_datetime.html, locals (). Note that now must be duplicated.
Locals () returns a dictionary containing all the variables and their values in the current scope. Therefore, you can rewrite views to def current_datetime (request): current_date = datetime. datetime. now () return render_to_response('current_datetime.html ', locals (). Note that you need to replace now
Locals () returns a dictionary containing all the variables and their values in the current scope.
So you can rewrite views
Def current_datetime (request): current_date = datetime. datetime. now () return render_to_response('current_datetime.html ', locals ())
Here, you need to rename now to current_date, because the template requires the variable name.
The template is defined as follows:
It is now {current_date }}.
Previously, because now is still used, the result is that the access time is http: // localhost: 8000/time/
Is displayed as blank.