0π
β
I found a very similar way to do it without Django templates that would have worked well for me at the time:
import re
tmpl = 'My name is (?P<name>.*).\nI like to ride my (?P<transport>.*).'
msg = 'My name is Adrian.\nI like to ride my bicycle.'
print(re.compile(tmpl).match(msg).groupdict())
Outputs:
{'name': 'Adrian', 'transport': 'bicycle'}
The XML regular expression template could still be kept in an XML file and read in at runtime.
π€Brad Pitcher
1π
As far as I know this is not a Django feature. So, no, there is no way in Django. If you have the template, you will have to create a way of parsing the html/xml, and compare it with the template in order to associate each change to each {{context_label}}.
This seems like an interesting problem, but I donβt see how its solution can be useful in a standard web-app (thus I see no reason why Django would have this feature in the first place).
π€Jorge Leitao
- [Django]-Unknown command: 'collectstatic' Django 1.7
- [Django]-ElasticSearch term suggest on analyzed field returns no suggestions
Source:stackexchange.com