Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Creating a PostgreSQL User and Database
Coming Soon. -
Running mod_wsgi in Daemon Mode
If you are tired of having to reload Apache each time you make a change to the Python files in Django then read on. There is a way around this and it is done by using mod_wsgi and running it in daemon mode which allows you to touch the WSGI file and have Apache automatically pick up on the changes you have made without having to restart. All you need to do is add the... -
Running mod_wsgi in Daemon Mode
If you are tired of having to reload Apache each time you make a change to the Python files in Django then read on. There is a way around this and it is done by using mod_wsgi and running it in daemon mode which allows you to touch the WSGI file and have Apache automatically pick up on the changes you have made without having to restart. All you need to do is add the... -
New Ventures
For the past month and a bit, I've been working part-time on my new venture. Along with Ben Firshman, I'm working on ep.io, a Python/WSGI hosting service, with resource-based (not instance-based) billing. It's been an interesting ride - designing shared hosting so it's both secure and so you can measure and bill resources accurately is a difficult task - but we're finally out of the woods and have everything working reasonably normally, leaving only the slow crawl of beta-testing and polishing (and working out a payment provider). We've also launched a blog, which only contains an initial post now, but it's where we'll be noting down what we've learnt, and general deployment advice, hopefully making it useful as a general learning resource as well as a corporate mouthpiece. Initially we've focused on supporting Django, as it's the thing Ben and I use most often, but the entire stack was built with general WSGI applications in mind (and, indeed, they do run). The stack we've built is quite flexible, so it could potentially be used for a variety of different languages or frameworks, but we think focusing on doing Python (and doing it well) is a good goal. If you want … -
New Ventures
For the past month and a bit, I've been working part-time on my new venture.Along with Ben Firshman, I'm working on ep.io, a Python/WSGI hosting service, with resource-based (not instance-based) billing. It's been an interesting ride - designing shared hosting so it's both secure and so you can measure and bill resources accurately is a difficult task - but we're finally out of the woods and have everything working reasonably normally, leaving only the slow crawl of beta-testing and polishing (and working out a payment provider). We've also launched a blog, which only contains an initial post now, but it's where we'll be noting down what we've learnt, and general deployment advice, hopefully making it useful as a general learning resource as well as a corporate mouthpiece. Initially we've focused on supporting Django, as it's the thing Ben and I use most often, but the entire stack was built with general WSGI applications in mind (and, indeed, they do run). The stack we've built is quite flexible, so it could potentially be used for a variety of different languages or frameworks, but we think focusing on doing Python (and doing it well) is a good goal. If you want to … -
django-static version 1.5 automatically taking care of imported CSS
I just released django-static 1.5 (github page) which takes care of optimizing imported CSS files. To explain, suppose you have a file called foo.css and do this in your Django template: {% load django_static %} <link href="{% slimfile "/css/foo.css" %}" rel="stylesheet" type="text/css" /> And in foo.css you have the following: @import "bar.css"; body { background-image: url(/images/foo.png); } And in bar.css you have this: div.content { background-image: url("bar.png"); } The outcome is the following: # foo.css @import "/css/bar.1257701299.css"; body{background-image:url(/images/foo.1257701686.png)} # bar.css div.content{background-image:url("/css/bar.1257701552.png")} In other words not only does it parse your CSS content and gives images unique names you can set aggressive caching headers on, it will also unfold imported CSS files and optimize them too. I think that's really useful. You with one single setting (settings.DJANGO_STATIC=True) you can get all your static resources massaged and prepare for the best possible HTTP optimization. Also, it's all automated so you never need to run any build scripts and the definition of what static resources to use (and how to optimize them) is all defined in the template. This I think makes a lot more sense than maintaining static resources in a config file. The coverage is 93% and there is an example app to look at in the if you prefer that over a README. -
django-static version 1.5 automatically taking care of imported CSS
I just released django-static 1.5 (github page) which takes care of optimizing imported CSS files. To explain, suppose you have a file called foo.css and do this in your Django template: {% load django_static %} <link href="{% slimfile "/css/foo.css" %}" rel="stylesheet" type="text/css" /> And in foo.css you have the following: @import "bar.css"; body { background-image: url(/images/foo.png); } And in bar.css you have this: div.content { background-image: url("bar.png"); } The outcome is the following: # foo.css @import "/css/bar.1257701299.css"; body{background-image:url(/images/foo.1257701686.png)} # bar.css div.content{background-image:url("/css/bar.1257701552.png")} In other words not only does it parse your CSS content and gives images unique names you can set aggressive caching headers on, it will also unfold imported CSS files and optimize them too. I think that's really useful. You with one single setting (settings.DJANGO_STATIC=True) you can get all your static resources massaged and prepare for the best possible HTTP optimization. Also, it's all automated so you never need to run any build scripts and the definition of what static resources to use (and how to optimize them) is all defined in the template. This I think makes a lot more sense than maintaining static resources in a config file. The coverage is 93% and there is an example app to look at in the if you prefer that over a README. -
django-static version 1.5 automatically taking care of imported CSS
I just released django-static 1.5 (github page) which takes care of optimizing imported CSS files. To explain, suppose you have a file called foo.css and do this in your Django template: {% load django_static %} <link href="{% slimfile "/css/foo.css" %}" rel="stylesheet" type="text/css" /> And in foo.css you have the following: @import "bar.css"; body { background-image: url(/images/foo.png); } And in bar.css you have this: div.content { background-image: url("bar.png"); } The outcome is the following: # foo.css @import "/css/bar.1257701299.css"; body{background-image:url(/images/foo.1257701686.png)} # bar.css div.content{background-image:url("/css/bar.1257701552.png")} In other words not only does it parse your CSS content and gives images unique names you can set aggressive caching headers on, it will also unfold imported CSS files and optimize them too. I think that's really useful. You with one single setting (settings.DJANGO_STATIC=True) you can get all your static resources massaged and prepare for the best possible HTTP optimization. Also, it's all automated so you never need to run any build scripts and the definition of what static resources to use (and how to optimize them) is all defined in the template. This I think makes a lot more sense than maintaining static resources in a config file. The coverage is 93% and there is an example app to look at in the if you prefer that over a README. -
django-static version 1.5 automatically taking care of imported CSS
I just released django-static 1.5 (github page) which takes care of optimizing imported CSS files. To explain, suppose you have a file called foo.css and do this in your Django template: {% load django_static %} <link href="{% slimfile "/css/foo.css" %}" rel="stylesheet" type="text/css" /> And in foo.css you have the following: @import "bar.css"; body { background-image: url(/images/foo.png); } And in bar.css you have this: div.content { background-image: url("bar.png"); } The outcome is the following: # foo.css @import "/css/bar.1257701299.css"; body{background-image:url(/images/foo.1257701686.png)} # bar.css div.content{background-image:url("/css/bar.1257701552.png")} In other words not only does it parse your CSS content and gives images unique names you can set aggressive caching headers on, it will also unfold imported CSS files and optimize them too. I think that's really useful. You with one single setting (settings.DJANGO_STATIC=True) you can get all your static resources massaged and prepare for the best possible HTTP optimization. Also, it's all automated so you never need to run any build scripts and the definition of what static resources to use (and how to optimize them) is all defined in the template. This I think makes a lot more sense than maintaining static resources in a config file. The coverage is 93% and there is an example app to look at in the if you prefer that over a README. -
Docs or it doesn't exist
Docs or it doesn't exist -
Introducing Shrubbery
Shrubbery is a collection of utilities for and extensions of Django. Its core feature are: App-local settings ORM extensions: fields, managers & querysets, multiple joins, and arbitrary queryset unions Polymorph relations (a replacement for django.contrib.contenttypes) A tagging app build on top of polymorph relations. I plan to describe most of these in detail in future posts. Meanwhile, there is some documentation. Shrubbery requires Django 1.3. It is available under the MIT License on github. -
Spatial Bookmarking Service goes Open Source
Locidesktop was my coffee shop coding project of last year. I was quite pleased with the results. Locidesktop.com has been happily serving link desktops to some loyal visitors for months now – with no maintenance required on my part (a good thing because I've been busy with other projects). Rather than let the project stagnate while I do other things, I have released it as open source with the hope that other Python/Django developers will pick it up and add new features. I had never really anticipated that anyone other than myself would see the code, so it is lacking in comments and documentations, but there are some nice features that may be of interest. For instance, there's a system to expose a REST API that factors out a lot of Python bioler-plate code and corresponding javascript code exposes the desktop functionality to the browser. There's also a pretty powerful caching system that makes rendering a desktop blindingly fast. I may have gone overboard with that, given my traffic rates. But I guess it is best to have more capacity than you need. If you want to look through the code or fork the project, it is available on Github: … -
Spatial Bookmarking Service goes Open Source
Locidesktop was my coffee shop coding project of last year. I was quite pleased with the results. Locidesktop.com has been happily serving link desktops to some loyal visitors for months now – with no maintenance required on my part (a good thing because I've been busy with other projects). Rather than let the project stagnate while I do other things, I have released it as open source with the hope that other Python/Django developers will pick it up and add new features. I had never really anticipated that anyone other than myself would see the code, so it is lacking in comments and documentations, but there are some nice features that may be of interest. For instance, there's a system to expose a REST API that factors out a lot of Python bioler-plate code and corresponding javascript code exposes the desktop functionality to the browser. There's also a pretty powerful caching system that makes rendering a desktop blindingly fast. I may have gone overboard with that, given my traffic rates. But I guess it is best to have more capacity than you need. If you want to look through the code or fork the project, it is available on Github: … -
Spatial Bookmarking Service goes Open Source
Locidesktop was my coffee shop coding project of last year. I was quite pleased with the results. Locidesktop.com has been happily serving link desktops to some loyal visitors for months now – with no maintenance required on my part (a good thing because I've been busy with other projects). Rather than let the project stagnate while I do other things, I have released it as open source with the hope that other Python/Django developers will pick it up and add new features. I had never really anticipated that anyone other than myself would see the code, so it is lacking in comments and documentations, but there are some nice features that may be of interest. For instance, there's a system to expose a REST API that factors out a lot of Python bioler-plate code and corresponding javascript code exposes the desktop functionality to the browser. There's also a pretty powerful caching system that makes rendering a desktop blindingly fast. I may have gone overboard with that, given my traffic rates. But I guess it is best to have more capacity than you need. If you want to look through the code or fork the project, it is available on Github: … -
Stupid Template Languages
For years I've been absolutely certain that I really prefer stupid template languages any time I'm generating HTML. The less the template language can do the better. Since I spend most of my time coding in Python you might assume this applies just to Python, but I think it also applies to anything where you have the power to readily mix HTML generation and code.The biggest annoyance I have with smart template languages (Mako, Genshi, Jinja2, PHP, Perl, ColdFusion, etc) is that you have the capability to mix core business logic with your end views, hence violating the rules of Model-View-Controller architecture. While the web can be hard to match to MVC, in general you aren't supposed to do that sort of thing. I've made the mistake of putting core logic in the wrong places in the past, but I'm proud to say I've gotten good at avoiding that particular mistake.I don't work in a vacuum.I often work on projects crafted by others, some who decided for arcane/brilliant/idiotic reasons to mix the kernel of their applications in template function/macros. This is only possible in Smart Template Languages! If they were using a Stupid Template Language they would have been forced put their kernel code in … -
LinkShare Pixel Tracking template tag for usage with Satchmo
I've implemented LinkShare Pixel Tracking for Satchmo-based stores — Django Snippet #2314. Very simple template tag which use info from current order and generate Pixel Tracking image link. -
Django forms ChoiceField and custom HTML output…
… or what to do in case that you need a special design for your choice fields The problem: Few posts ago I talked(wrote) about Django forms ChoiceField and with dynamic values and now it is time to take a look at the front end and how we display these values to the user. I [...] -
Extending Django CMS Page model – part III
… or the drawback of Extending Django CMS Page model – part II First of all please accept my apologies that I couldn’t warn you for this drawback earlier but I was really busy in the last few weeks so let’s skip directly to the problem. If you remember in Extending Django CMS Page model [...] -
Serving favicon in an Django App using Apache
I got a free few minutes to work on my own site here. Since I migrated the site from all static pages to Django served, I still haven’t put back the favicon icon back onto the site. The sites runs under a virtual host in apache2 at WebFaction. This is what you need to put [...] -
Django CSRF Migration
Like many of you, I am migrating all my Django sites to Django 1.2.1. For sites that are currently in production, I am doing the slow migration route. Just trying to get the site up with 1.2 without using any of the new features yet. One thing that I ran into is the new CSRF [...] -
Django South Explained
Posted my tutorial on using Django south, the database migration tool, over at DjangoPro. Check it out! -
Resetting Django Admin Password
This barely qualifies for a blog post, but what to do if you loaded, via django-admin.py loaddata a full json file from someone during testing, and don’t have their user’s password? Just run the django-admin.py shell, and by hand reset all the passwords: from django.contrib.auth.models import User for u in Users: u.set_password(‘secret’) u.save() That’s why [...] -
Django Production Error Handler
I am working on an application that, besides providing a dynamic website, also talks to an iPhone application. What happens when the iPhone, or a web visitor, triggered a bug in the application? Django actually provide a nice mechanism to report error in its “batteries included” goodness. You can easily setup the Django environment so [...] -
Fix Python source code to use spaces instead of tabs
What if someone gave you a Python source file that is indented using tabs? If you are using emacs, the following will let you convert it back to using spaces: # first set the buffer tab width to 4 (or whatever you like) M-x set-variable <return> tab-width <return> 4 # then mark the entire file [...] -
Paul Bissex Presenting at the Boston Django Meetup 2010
Paul Bissex, author of “Python Web Development with Django”, described how he use Django to replace two legacy desktop applications at hallmark.edu at the Boston Django meetup this month. Because of Django’s ease of use and robustness, not only he replaced and deploy those apps easily, the apps has been running error free for a [...]