1👍
✅
That refers to a specific way to use the % string-formatting operator:
print "Hello, %(thing)s!" % {"thing": "world"}
prints “Hello, world!”
You want to use a redirect URL like ‘/%(school_slug)s/%(menu_type_slug)s/print/’, the redirect view will receive a kwargs dictionary with keys ‘school_slug’ and ‘menu_type_slug’ and use it as argument for %.
1👍
It refers to formatting strings by interpolating entries from a dictionary into a string:
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
>>> "%(pwd)s" % params 1
'secret'
If I interpret the Django documentation correctly, you can only use this to substitute URL query parameters, which are of the form kwd=value
. The components of the path are not available for substitution.
- [Answered ]-Display Word Count in Blog Post with Wagtail
- [Answered ]-Django codemirror get code from editor
- [Answered ]-Django 1.8 – 'NoneType' object has no attribute 'aggregate'
- [Answered ]-Django: getting m2m values after model_save
- [Answered ]-CherryPy with Cheetah as plugin + tool – blank pages
Source:stackexchange.com