Template Loading
If you’re following along, open your settings.py and find the TEMPLATE_DIRS setting. By default, it’s an empty tuple, likely containing some auto-generated comments:
"C:/project web/templates",
# Always use forward slashes, even on Windows.
Note
Windows users, be sure to use forward slashes rather than backslashes. get_template() assumes a Unix-style file name designation.
Moving along, create the current_datetime.html file within your template directory using the following template code:
toring templates in subdirectories of your template directory is easy. In your calls to get_template(), just include the subdirectory name and a slash before the template name, like so:
or with shortcut
The first argument to render() is the request, the second is the name of the template to use. The third argument, if given, should be a dictionary to use in creating a Context for that template. If you don’t provide a third argument, render() will use an empty dictionary.
Because render() is a small wrapper around get_template(), you can do the same thing with the second argument to render(), like this:
No comments:
Post a Comment