-
Recent Posts
Github badge
StackOverflow badge
How to read this blog
This blog should be read like all other specifications. First, it should be read cover-to-cover, multiple times. Then, it should be read backwards at least once. Then it should be read by picking random sections from the contents list and following all the cross-references.Promote JS
Category Archives: django
Sepia images with Django, Python and Sorl-thumbnail
Meet Sorl-sepia, a Sorl engine backend (PIL only so far) to turn your images into sepia tones. See the README file for instructions. Continue reading
Posted in django, en, programacion, Python
Leave a comment
UnicodeEncodeError on Django uploaded files
This has been an error that’s been bugging me for months. For some reason in production settings only in the production server only, whenever a user uploaded a files with a non ascii filename, I’d get this error UnicodeEncodeError: ‘ascii’ … Continue reading
Posted in django, en, programacion, Python, tech, web
Leave a comment
Django random object manager
Several times in the past I needed to fetch a list of random objects. And Today I decided to make a Mixin class to add a get_random() method to my managers: # -*- coding: utf-8 -*- from random import sample … Continue reading
Add ‘error’ class to widgets with errors in Django Forms
Many times UI requires us to style differently widgets that have errors in a field instead or next to an error message. Django provides a nifty .errors attribute to tell if a field of form has errors but you can’t … Continue reading
Generating Javascript Widgets with reversed URL endpoints in Django
I just read Elf Stenberg’s solution on how to serve static Javascript with reversed URLs in Django, I was going to leave this as a comment but I better explain it here When developing Django Widgets that require Javascript interaction … Continue reading
Django 1.0 Template Development
Last month I got an email from Packt telling me about their latest book on Django Template development. I was invited to give it a read and see how I liked it. Now, I’m a lazy and slow reader. But … Continue reading
So it has a snake inside doing all the magic!
Great drawing used by the Nebula team at Nasa to show proudly that they use Django for their development.
Using object_list generic view for pagination in Django
Whenever I want to display a list of items I’ll need pagination, calculate first page, next page, total pages, current page, previous page, etc. Although Django comes with pretty good pagination helpers, I’ve found that using the list_detail.object_list generic view … Continue reading
Access MEDIA_URL from static Javascript files in Django
This is an old trick, that’s been very handy . Many times for various reasons you’ll need to access your media files from your Javascript files, to display images, change paths, or whatever. And in most cases your development MEDIA_URL … Continue reading
Django cheap pages
Sometimes I end up using Django for the wrong thing, just to dispatch pages and put all my content in the templates. Flatpages are too flat and other DB based content tools are too complex. I just want to use … Continue reading
