Blog / Django

Give your Django app more of a native mobile app feel with Chrome for Android's 'Add to Homescreen'

February 10, 2015

A user of one of my Django apps, GlucoseTracker, suggested this to me last week and I actually didn't even know this feature existed. I thought it was a really great idea and it turned out it can be done easily with about 3 lines of additional code:

# base.html

<!doctype html> 

      <!-- Enables 'Add to Homescreen' for Android -->
      <meta name="viewport" content="width=device-width">
      <meta name ...

Haystack with Solr: Indexing Tips

January 22, 2015

I was troubleshooting an issue a couple of weeks ago with some of our Django views taking too long to return a response. The issue was due to post_save and post_delete signals making a request to Solr to update the index with the 'commit' parameter set to 'true' (Haystack default). This basically tells Solr to do the indexing right away (hard commit) and it was taking a few seconds to finish.

Below are some tips ...

Adding basic search to your Django site

January 17, 2015

While most people probably find content on your site through Google, it might still be a good idea to just add a basic search functionality to it. You can control which fields to search, how your results are displayed, and your readers won't have to leave your site. You may also have content that is not yet public that you want to be able to search, such as unpublished articles or blog posts.

For ...

Adding responsive tables (no scrollbars) to your Django app with DataTables

January 13, 2015

It had been over year since I last looked at DataTables, a jQuery table plugin for creating tables with advanced features. I used it for my Django app, GlucoseTracker, and it worked great. But one thing that was bothering me was it wasn't responsive. It was the only element in my app that wasn't responsive and looked horrible when viewing on a phone in portrait mode.

Over the weekend I decided to check ...

EZ Price Alerts: A Django app for tracking Amazon prices

December 28, 2014

EZ Price Alerts

A friend and I started working on this project a few weeks ago as we were talking about the holidays and how useful it would be to build an app to track prices of products on We know Amazon is very competitive with their pricing and their prices for certain products could change many times a day to match competitors'. Having an app to send you alerts when a product reaches your desired ...

Adding drag and drop image uploads to your Django site in 5 minutes with DropzoneJS

November 28, 2014

I've been using the Django admin to upload images to my site one-by-one for a few weeks now and I've finally decided I've had enough of it and started looking for a Javascript library that will enable me to do bulk uploads.

I still have around 100 or so albums and at least 1,000 more pictures to upload so you can just imagine how tedious that would be. I found this ...

How to disable the 'Invalid HTTP_HOST header' emails in Django

November 22, 2014

Ever get these annoying admin emails?

Invalid HTTP_HOST header: ''. You may need to add u'' to ALLOWED_HOSTS.

Request repr():
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
'HTTP_HOST': '',

The reason you're getting this is because someone's trying to access your site via a host not listed in your ALLOWED_HOSTS setting.  In my case, for this blog, I have ...