Ajax blocks in Django

, , django, ajax, templates

Quite often we have to write paginated or filtered blocks of information on page. For example, list of similar houses. It's rendered on server first, and later pagination is done with ajax.

In order to make, I used following setup:

  • inclusion tag, that generates context for tag
  • view, that parses request params and them launches the same tag to create context
  • So in order to edit one such block, we have to edit three files (apart from template) - tag, view, url.

    I got annoyed by this and decided to create a decorator that would automate this process.

    With this decorator, you just have to write one function that creates context. Tag and view are generated and registered automatically. Url params like ?obj_id=1 are declared in decorator and are processed automatically.

    contact us right now