Articles Tagged ajax
File management with django and yawd-elfinder.
I've always liked elFinder. It is a jQuery application that allows for managing files through a web page. elFinder is capable of uploading, moving, previewing and editing all kinds of files on the fly. In version 2 you can also resize, rotate and crop your images online, so it is a perfect solution for your django website's administration interface. To integrate elfinder with django we created a reusable django application, the yawd-elfinder. In this simple tutorial we will install yawd-elfinder and connect it to our models. For more control over your files, please advice the documentation.Posted on September 24th, 2012 by Pantelis Petridis
Figure 1. Ajax coin slider - screenshot from the yawd website
Since Django 1.3 class-based views have been introduced to allow for code reusability. Class-based views have been criticized for their poor documentation (count me in) and their amazing ability to grow our code size instead of reducing it! The latter appears to be true only if we are not careful with sub-classing. On the other hand class-based views finally deliver django what has been missing: a consistent way of coding all your models, forms and views.Unfortunately, django's generic class-based views do not provide a mechanism for implementing JSON views. Ajax requests are the standard way of doing things these days and I feel that django needs some work towards this direction. However, the official documentation offers the implementation of a simple JSONResponseMixin that we will use as a base for our own view. What we try to achieve here is create a view that will process a form, return the errors when the form is not valid or save the form and return a success message otherwise. This is a fairly common scenario and extremely useful when a full page reload is not acceptable (e.g. a newsletter subscription form).Posted on August 30th, 2011 by Pantelis Petridis