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 :)

  1. why type ng-app="" ? should put here name of angularjs application. did create angularjs module first?
  2. you can sort both in frontend , backend, should in frontend - job of web browser - backend should responsible generating data consumed frontend.
  3. something {% fault in faults|dictsort:{{sort_by}} %} can't work. try define angularjs variable called sort_by, , use in django filter. django doesn't know nothing variable.
  4. both django , angularjs use {{}} variable bindings in templates. can change these symbols angularjs or use verbatim , endverbatim tag in django.

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -