Blog

Bring back old Bangla font in Safari OS X 10.11 El Capitan

Apple changed the default Bangla font to Kohinoor Bangla on El Capitan. However, you can bring back the old font (BanglaSangamMN) in Safari very easily. Click Here to download the necessary files. Put user-style.css along with other files in a folder. Then open Safari & go to Preferences > Advanced. Now click on the dropdown […]

Scrubs! What a show!

It’s really hard to find a decent TV show after you’ve watched over 50 shows, trust me. Most of the shows you choose will seem boring at some point. I never thought I’d find a show for which I have to make a room in the top 3. Scrubs did it! Scrubs is the show […]

Serving Django static files in shared hosting

I kept my django project files out of public_html. You probably know the reason – to prevent direct access to those folder/scripts. Since the static files aren’t inside “public_html” we need to provide some way to access them. Consider the following 1. The project ‘myapp’ is in /home1/myuser/django/ 2. ‘static’ folder is in myapp/static 3. […]

A dynamic template filter for django forms

I used to assign attribute to form controls like this: But this just doesn’t feel right. Wouldn’t it be so much better if we could do this in the template and may be by writing less code? Okay, here’s my solution: file: forms_attr.py put this file in templatetags folder of your app. And then in […]

ActionBar Tab + Spinner(List) navigation at the same time

So I was looking for a solution to this particular problem & saw lots of question regarding this on Stackoverflow, But none came up with a solution that works. After several hours of research I managed to find a way to do this. The idea is very simple. There’s a title bar just beside the […]

Migrating from Django template to Jinja2

Jinja2 is great. Far better than the django template I think. But I’m not here to talk about that. My guess is you already decided to use Jinja2. So let’s talk about the changes you need. 1. You can use Jingo to set it up easily. install: Create a file e.g. ‘jingo_settings.py’ & paste the […]

DJango ORM: Sum of multiplication

Consider the following model: Now to calculate sum of progress*estimated_days follow this: Note: if two fields are of different types, say integer & float, the type you want return should be passed as the first parameter of Sum.

var_dump for python

var_dump is a PHP’s var_dump() equivalent function for python. It displays structured information such as type, value etc of a python object, list, tuple, dict & other types. Installation using pip Or clone the project & cd into the `python-var_dump` directory then run: Examples Example #1: Example #2: you can pass more than one argument: […]

Custom validation in Django Admin list view

In my previous post, I explained how to apply Custom validation in Django admin form. But we can also make one or more field editable in the list view. In this post I’m going to explain how to apply custom validation in list view. We’ll just modify the CountryAdmin class described in the previous post. […]

Custom validation in Django admin form

Django applies the validation rules defined in the Model or Form. But sometimes we might need custom validation in Django admin forms. Let’s assume that we are developing an app that’ll store all of the countries data. We’ll also feature 5 of them in the homepage of the app. Let’s consider the following Model file: […]