How to write custom Django admin actions

Django admin actions are simple functions that provide an easy way to apply a given command to the selected objects in an admin change list view. By default Django ships with a “delete selected objects” action available to all models.

Django admin actions example

read more

How to write and use custom template processors in Django

Instead of repeatedly adding the same content is many places in your Django templates, you can write context processors to make it “globally” available for use in all templates. This helps to reduce on both code and data redundancy.

read more

Pagination in Django

In web applications, there is usually a need to display large datasets. Displaying the whole dataset in a single web page at a go may easily choke/misuse computer resources such as memory. Again, no one loves sluggish and slow web pages. Some users may stay after throwing a few curses while others may angrily turn away.

read more

Custom Django management commands

In many computer applications there is usually a need to execute some actions by use of command line interfaces. The inbuilt argparse python module provides a simple way of writing such interfaces. Click is a third party python module which solves the same problem but provides a richer set of features and arguably a better developer experience compared to argparse. Generally, when there is a need to build complex python command-line interfaces it is advisable to use Click or any of the other third party solutions because of the many useful abstractions they provide.

Django management commands are Django’s own way of writing command-line interfaces. The utilitiy is used to register and run these commands.

read more

Beauty in software and literature

For the few who have a passion for both literature and software(I take the pleasure of considering myself one of these), there is a great semblance in the beauty that is seen in an artistically written piece of literature and that evident in a well crafted piece of software. The reverse is also true. The ugliness seen in either of these likewise bears the same semblance, arguably caused by ignoring similar principles and ingredients requisite for rendering such works elegant.

read more

Use of third party libraries in software projects

In any software project of considerable complexity, it is often wise to look out for libraries which implement some of the functionality one needs and add such libraries to the project as third party libraries. The main reason for doing this is to avoid reinventing the wheel. It is a sheer wastage of time to write a new piece of software which has already been written, debugged, refactored and optimized a thousand times over by others in the open source community.

read more

Subscribe to our Newsletter

Receive updates when we add new content. No spam or some funny tricks.