now browsing by category


Django Unit Testing with Mocks

Unit tests shouldn’t be treated like lesser code. It should be as clean as possible and don’t ever hesitate when it comes to refactoring the unit test code. It can save you a lot of trouble in the long run.

Working on a django site

Working on a django site at work, it’s not bad, however still working with angularjs code after work and on the weekends.

Disable CSRF Verification in Django Class-Based View with csrf_exempt

While working on a Django web app, I had to disable CSRF protection in a view. The goal was that our API was accepting data from another part of our website and we needed to skip the CSRF protection just for that one page. There are two great answers onRead More

Django filter versus get for single object?

Django filter versus get for single object? While at work, we use a particular pattern in Django for getting a single object. We first filter the queryset by the id or slug and then check if the queryset exists. If so, then we return the object otherwise we return none.Read More

Validating File uploads in Django 1.0

While working on Clapton, the Django-based Content Management System (CMS), I had to write validation code for file uploads. This is needed because Clapton contains applications specific to media types such as documents which requires Word Documents, PDFs or OpenDocumentFormat files, and podcasts which requires MP3 or OGG files. But how doRead More