I need to write a .format() like this:
"{% display_cookies_accepted {} %}".format(self.client.cookies)
{} - need to be replaced by self.client.cookies
{%, %} - is a template tag in django syntax.
How to make it working?
"{{% display_cookies_accepted {} %}}".format(self.client.cookies)
also fails.
Just format the content first, and then add the django tags.
"{%" + " display_cookies_accepted {} ".format(self.client.cookies) + "%}"
Or put the tags in the format as well.
"{} display_cookies_accepted {} {}".format('{%', self.client.cookies, '%}')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.