python - dynamic sorting template in django -
i have problem 1 idea (dynamic sort template in django)
now have solution sorting data not because have couple of buttons adnotate sorting view , in way have sorted list of data.
i tried use angularjs, think best way have problem too. example:
<div ng-app="" ng-init="sort_by = 'updated_at'"> <button ng-click="sort_by = 'id'">id</button> <button ng-click="sort_by = 'created_at'">created_at</button> <button ng-click="sort_by = 'issuer'">issuer</button> <button ng-click="sort_by = 'handler'">handler</button> <p>{% verbatim angular %} {{sort_by}} {% endverbatim angular %}</p> {% fault in faults|dictsort:{{sort_by}} %}
in theory can works. not.
i try in way , in apostrophe , try block above {% verbatim angular %} , not working giving me error this:
'for' statements should use format 'for x in y': fault in faults|dictsort:'{% verbatim angular
so not recognizing angular block.
i have ask , doesn't have angular, if better idea in template or maybe stricte django way??
thanks me :)
- why type
ng-app=""
? should put here name of angularjs application. did create angularjs module first? - you can sort both in frontend , backend, should in frontend - job of web browser - backend should responsible generating data consumed frontend.
- something
{% fault in faults|dictsort:{{sort_by}} %}
can't work. try define angularjs variable calledsort_by
, , use in django filter. django doesn't know nothing variable. - both django , angularjs use
{{}}
variable bindings in templates. can change these symbols angularjs or useverbatim
,endverbatim
tag in django.
Comments
Post a Comment