In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to parse the views and templates of Django, for this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
I. View and template 1, function view
A view defined as a function is called a function view, which is easy to understand. However, when you encounter a path corresponding to a view that provides support for many different HTTP request methods, you need to write different business logic in a function, but the code readability and reusability are not good (class view will be used later).
Defining a function view is exactly the same as defining a function, except that the function view must accept a parameter request.
2. Template file
① defines rout
② definition function view
You can now see the output text, but the requirement is that the display returns a static page. Template support is required.
③ establishes template folder and static resource folder static
④ places static pages and static resources in the corresponding directory
⑤ configures static resources in setting.py
⑥ loads the page in the function view
The render method calls the load template method
Render (request, template name)
⑦ modifies the access address of static resources on the page
The path to the css js img picture plus / static
This is the answer to the question about how to parse the view and template of Django. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un