Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Deploying Django
It's been a while between posts, and also between Django projects, but coincidentally with the release of 1.2 I've found an excuse to work with Django again, and have decided to release my own Django deployment library based on fabric called woven. More on that in a minute. Deployment of Django projects has always been a bit harder than it should be. I understand why Django hasn't gone down the -
Django model definitions can’t be reloaded
I spent way too much time this evening figuring this out. If you have a models file like this (artificial, but play along): from django.db import models from random import random rand_val = random() class MyModel(models.Model): r = rand_val After you import MyModel in some other module, you can’t re-load the class definition of MyModel. [...] -
Getting Started with South (Django Database Migrations)
The very bare bones steps to getting up and running with South for your Django database migrations. -
Using virtualenvwrapper to start processes and swap config files
I do my Django development work locally on OS X, so I have several different daemons installed on my machine. I used to keep Postgres, MySQL, lighttpd, memcached, and more set up to autostart and run continuously, but I didn't like the burden on performance (real or imagined). Also, I switch between projects frequently and I often need to switch config files based on the project I'm about to work on. My solution is to use the end-user customization hooks that Doug Hellmann's excellent virtualenvwrapper provides. If you're not familiar with virtualenvwrapper, it makes it easy to manage your virtualenvs in one place and switch between them quickly and conveniently. The project provides several scripts that are meant to be added to by the end-user to customize behavior. Configuration For my configuration files, I create multiple versions with the changes needed for each project, and I then create a symlink to the version I want at the moment. For example, with lighttpd I'll create an /etc/lighttpd/project-a.conf and an /etc/lighttpd/project-b.conf, and then create a symlink called /etc/lighttpd/lighttpd.conf that points to the one I need. In OS X, I use launchd .plist files that have the OnDemand option set to True. I've … -
GSOC Status Update
This past week I worked up updating the model tests, and committed 7 changes. I did an analysis of the rate at which I need to finish the project, and I’m going to aim for converting 25 tests a week. I’ve gotten better at formulating unittests and have learned a bunch of useful emacs features. [...] -
Using Arecibo and Django, the easy way
So you've got your Django project on the production server. Want an easy way to track the errors in Django? The existing Django package is pretty easy to use, but it doesn't get much simpler than this: add in your Arecibo server to your ADMINS in settings.py. When Django emails out those error emails, it will send one to Arecibo. Arecibo will parse it and add it your site. The email address for that is: django-YOUR_PUBLIC_ARECIBO_KEY@yourserver.appspotmail.com. You can try this out right now, the email address for the test server is: django-sw3tqw35ywq45ws4kqa4ia6yw5q45serws23w351245lk6y@test-areciboapp.appspotmail.com Becomes: To do this we are parsing the email down, which is less accurate than just doing a HTTP post via the API, but its pretty easy to setup. Note: the key for the email address for the test server might change, you can find it on the setup pages on the test server. All errors are deleted after one hour on the test server. -
Review: Django 1.2 e-commerce
I already have Beginning Django E-Commerce. When Django 1.2 e-commerce came out, I thought, sure, why not. I’m a pushover for a good technical book. It has positive buzz, modulo some rumblings about glaring errors in the code samples. The quick details Chapter 1: What’s Django and why it’s good for e-commerce. Zzzzzzzz… Chapter 2: Quickly [...] -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
PyFilesystem 0.3 released
I am pleased to announce a new version of PyFilesystem (0.3), which is a Python module that provides a common interface to many kinds of filesystem. Basically it provides a way of working with files and directories that is exactly the same, regardless of how and where the file information is stored. Even if you don't plan on working with anything other than the files and directories on your hard-drive, PyFilesystem can simplify your code and reduce the potential of error. PyFilesystem is a joint effort by myself and Ryan Kelly, who has created a number of new FS implementations such as Amazon S3 support and Secure FTP, and some pretty cool features such as FUSE support and Django storage integration. As an example of how awesome this package is, take a look at the following 6 lines of code, which creates a ramdrive: from fs.osfs import OSFS from fs.memoryfs import MemoryFS from fs.expose import fuse home_fs = OSFS('~/') home_fs.makedir('ramdrive', allow_recreate=True) fuse.mount(MemoryFS(), home_fs.getsyspath('ramdrive')) If you run this, a directory called ramdrive will appear in your home folder, the contents of which are stored purely in memory. I prepared a screencast that gives a quick demonstration of some features – because … -
Django-improved-inlines, enrichissez facilement vos contenus et ça, sans payer l’ISF
La pluie ayant décidé d'être l'invité surprise du week-end, j'ai donc une bonne excuse pour ne pas aller prendre des coups de soleil à la plage mais rester bien tranquillement sur mon clavier. Autant donc en profiter pour vous parler de l'application django du mois, j'ai nommé django-improved-inlines. Oui, je sais, elle a un ... -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Review of Django 1.2 E-commerce
I've worked with Django for more than two years now. The majority of the sites I have worked on have been social-networking or content based, but I have yet to do any serious work on a site where the main purpose is to advertise and sell products. So I when a copy of ‘Django 1.2 e-commerce’ landed on my desk I was intrigued by what it might cover that I hadn't been exposed to with other fields of Django development. Django 1.2 E-commerce The book starts out with a brief run-down of Django. The first chapter is more of a explanation of the philosophy behind Django, and definitely not a tutorial. Which I think is fair enough; if you are building an e-commerce site, you are probably a professional Python developer and there are plenty of books to get you up to speed with Django. In the second chapter, the author runs through a simple web-shop application with an inventory and a ‘buy now’ button – which seemed more like a confidence building exercise than anything else, but it does do a good job of demonstrating how simple it can be to build this kind of application with Django. The … -
Aptana Studio and “Undefined variable from import: DoesNotExist”
Teaching Aptana Studio about DoesNotExist -
Falsehoods Programmers Believe About Names
Falsehoods Programmers Believe About Names. People’s names are complicated. I’m not at all comfortable with the commonly used first name / last name distinction (as baked in to Django auth) since it doesn’t take cultural factors in to account. -
Quick shell command to add CSRF token
To get the benefit of Django 1.2's new CSRF protection, all POST forms will need a special token. Here is a quick command that runs through templates adding the token: find . -type f -name "*.html" -exec sed -i \ 's|\(<form[^>]*method="post"[^>]*>\)\({% csrf_token %}\)\?|\1{% csrf_token %}|g' \ {} \; -
Using Fabric For Deployment
In a previous post I discussed what you want from an automatic deployment system. In this post I’ll discuss how use to solve the repeatability and scalability requirements that I set out. Fabric is a tool which lets you write scripts to automate repetitive tasks. So far, so bash like. What sets Fabric apart is [...] -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
Announcing Sore Thumb, a thumbnail and image processing module for Django
I recently worked on the re-design of 2 Degrees, which required a lot of image processing on thumbnails. The thumbnails where to be in a variety of different sizes, all with rounded corners and keylines on a selection of virtually identical off-white backgrounds and gradients. And they all had to work on IE6 *spit* without the transparency hack. A variety of thumbnails generated by Sore Thumb A lesser engineer may have told the front-end developer where to stick his rounded corners, but I didn't want see a grown man cry, so I built Sore Thumb, an on-the-fly thumbnail and image processing system for Django. Sore Thumb uses a declarative method of defining thumbnails, similar to Django's model and form definitions. Here's an example of how to declare a thumbnail processor that produces a 120x100 pixel thumbnail with 10 pixel rounded corners and a dark grey keyline: from sorethumb.djangothumbnail import DjangoThumbnail from sorethumb.filters.defaultfilters import ThumbnailFilter from sorethumb.filters.drawfilters import RoundedCornerFilter class RoundedCornersEdged(DjangoThumbnail): format = 'png' filters = [ThumbnailFilter(120, 100), RoundedCornerFilter(10, border='#333')] Once this class has been imported, the thumbnail processor will be available in templates via the sorethumb filter which takes a Django FileField and returns the url to the thumbnail. For … -
The syncbox
I move between a couple different computers regularly: my old 12" PowerBook and the 15" MacBook Pro my job provides me with. Like all multi-computer users I periodically bump up against the challenges of what files (and versions) are where, especially when there's work in progress. To further complicate things, I also have an extra laptop running Ubuntu. And sometimes I just SSH to my web server from somebody else's machine. I spent a while thinking about solutions. Some people keep a "master" home directory on a server, using rsync to pull new copies (or freshen old copies) on machines where they work. Being an rsync fan, I tried this approach. After my first accidental rsync --delete casualty, though, I started thinking about ways to preserve history. That's when the ideal solution hit me (making a big resonant "DUH" sound): distributed version control. Perfect synchronization: check. Multi-platform clients: check. Full history: check. I created a Mercurial repository on my web server, then cloned it out to the two laptops. For stuff that needs to be secure, I decided that simple command-line encryption was the answer (hence this tweet from a while back with a Blowfish encrypt/decrypt one-liner). And I use … -
Migració a postgres des de sqlite
Pels qui no ho sabíeu aquest blog corria damunt una base de dades sqlite3. La base de dades és prou ràpida per les necessitats d'un blog com aquest, però té un emperò considerable: consumeix molta memòria comparada amb un mysql o postgresql. Quan el blog duia una parell de setmanes amb visites que consultàven molts apunts, sqlite començava a cachejar i el consum de memòria de l'aplicació del blog es disparava fins als 160 Mb, mass si ho comparam amb altres aplicacions tant o més complexes que executant-se amb Postgresql estàven entre 30 i 50 Mb. El consum de Postgres és una altra cosa, però com que es reparteix millor entre les aplicacions el resultat final és un estalvi de memòria. El procés per passar d'sqlite3 a Postgres ha estat el següent: Feim un dump de les dades cap a json. Això es pot fer des de Django amb la comanda dumpdata, per exemple: python manage.py dumpdata contenttypes > dumps/contenttypes.json He fet dumps de sites, auth per la part d'usuaris, contenttypes, i després de tota la resta d'aplicacions que fa servir el blog. Cream la base de dades i l'usuari a Postgresql que farem servir, donant-li permisos de creació de … -
Lately
I have really gotten out of the habit of blogging and I hate that. It's not because I don't have anything to talk about. Quite the contrary -- a lot has been going on. I thought today would be a good chance to provide a recap of things I have been doing and thinking. StudioNow / AOL Back in January, the startup I have been working on since very close to it's beginning three, well almost four years ago now, was acquired by AOL. This has been the single best experience of my career. To build something from scratch that didn't exist before with a group of really smart folks and turn it into something valuable enough for someone else to purchase at a multiple that made everyone involved happy. I started off not knowing anything about Python, about ffmpeg, about video on the web, much less anything to do with cloud computing. Looking back at what we have accomplished technically, and I wouldn't have thought it possible or likely been able to fully grasp when first starting. I am now close to 6 months on the other side of the acquisition as a full time employee of AOL. I … -
Lately
I have really gotten out of the habit of blogging and I hate that. It's not because I don't have anything to talk about. Quite the contrary -- a lot has been going on. I thought today would be a good chance to provide a recap of things I have been doing and thinking. StudioNow / AOL Back in January, the startup I have been working on since very close to it's beginning three, well almost four years ago now, was acquired by AOL. This has been the single best experience of my career. To build something from scratch that didn't exist before with a group of really smart folks and turn it into something valuable enough for someone else to purchase at a multiple that made everyone involved happy. I started off not knowing anything about Python, about ffmpeg, about video on the web, much less anything to do with cloud computing. Looking back at what we have accomplished technically, and I wouldn't have thought it possible or likely been able to fully grasp when first starting. I am now close to 6 months on the other side of the acquisition as a full time employee of AOL. I …