Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
FOSDEM 2011 and GNOME Foundation
That’s right, once again I could count on Igalia‘s kind support to be able to go to this great conference one more year. Just like last year, I’m giving two presentations: * Making the printed world accessible: A11y in OCRFeeder, in the Accessibility DevRoom on Saturday at 11:00; * Grilo: Integration of Multimedia Contents in [...] -
FOSDEM 2011 and GNOME Foundation
That’s right, once again I could count on Igalia‘s kind support to be able to go to this great conference one more year. Just like last year, I’m giving two presentations: * Making the printed world accessible: A11y in OCRFeeder, in the Accessibility DevRoom on Saturday at 11:00; * Grilo: Integration of Multimedia Contents in Applications Made Easy, in the CrossDesktop DevRoom on Sunday at 13:45. This will be my fourth time attending FOSDEM and every year I love it more. In what other conference can you attend presentations about: GNOME, MeeGo, Django, Accessibility and much, much more. And let’s not forget about the Friday Beer Event, that allow us hackers to socialize while sipping on the finest beers on earth. And of course, to some of you, I don’t need to tell again how much I like Brussels, and Belgium in general. By the way, this year there is a new, more Maemo-ish, FOSDEM Maemo app called Sojourner which will help you schedule the talks you wanna attend, so, be sure to install it in your N900. (I’ve contributed with a couple of patches last Friday, which are pending integration ) Other news from my part is that since … -
Jimmy Page: site-wide Django page caching made simple
For some time, I've been using the per-site cache feature that comes included with Django. This site's caching needs are very modest: small personal site, updated infrequently, with two simple blog-like sections and a handful of static pages. Plus, it runs fast enough even without any caching. A simple "brute force" solution like Django's per-site cache is more than adequate. However, I grew tired of the fact that whenever I published new content, nothing was invalidated in the cache. I began to develop a routine of first writing and publishing the content in the Django admin, and then SSHing in to my box and restarting memcached. Not a good regime! But then again, I also couldn't bring myself to make the effort of writing custom invalidation routines for my cached pages. Considering my modest needs, it just wasn't worth it. What I needed was a solution that takes the same "brute force" page caching approach that Django's per-site cache already provided for me, but that also includes a similarly "brute force" approach to invalidation. Enter Jimmy Page. -
Actualitzant coses
Aquesta setmana he estat força entretingut, m'he estat mirant un grapat de llibreries i utilitats, algunes d'elles noves versions que han anat evolucionant i millorant al llarg del temps. També vaig tenir l'oportunitat d'assistir a la xerrada de Maria Antònia Mas Pichaco damunt la guia PMBOK®, gràcies a l'empenta de Paco que em va recordar que es donava la xerrada. A part de la conferència en sí, també va estar molt bé el cafetó i la xerrada amb Paco, això de contar batalletes i compartir opinions no s'ha de perdre Paco! :) Xerrada de PMBOK® Si anam per ordre el primer seria parlar de la xerrada de Maria Antònia. A diferència d'altres assistents que l'havien tinguda com a professora, era la primera vegada que l'escoltava. Em va agradar, la exposició va ser clara i entretinguda. M'hauré de llegir la guia per poder-ne fer una avaluació en profunditat, però pel que vaig entendre es tracta d'un conjunt de recomanacions i millors pràctiques que cobreixen el cicle de la gestió de projectes, però que en cap cas ens marca un camí a seguir o una metodologia. Supòs que la utilitat vindrà quan ja hagis elegit com gestionar un projecte. En la part … -
Evaluating Django Caching Options
Caching is one of the first things you can do when you need to start thinking about scaling. Among efforts such as query minimization, denormalization, code optimizations, compression, database tuning, indexing, and load balancing, caching remains one of the lowest hanging fruits in methods to lighten your server load and handle huge amounts of traffic. There are many options, and I chose to evaluate a few of the most interesting setups.This is not intended to be a rigoriously scientific test, but more of a first impression of the different caching systems. For all the tests I'm describing, I'm using a single VPS on Rackspace Cloud with 320MB of RAM, a quad-core AMD Opteron 2350HE, and a bleeding edge server stack using Ubuntu Server 9.10, NGINX with UWSGI, Python 2.6, Django 1.1, and PostgreSQL 8.4. I'm serving the home page view of Django-Mingus, which provides a realistic amount of complexity to the Python side of things and gives us a 9387 byte response. I'm using 4 UWSGI processes and a single NGINX worker. All my tests are using ApacheBench, which I'm running on the same machine. Note that for all my cache tests I'm prepopulating the cache before running the benchmark. … -
Django Template Tag Namespaces Now Possible
I've been interested in the Django template language for some time now, and I've admired much of its simplicity and extendibility. I even wrote a shell for it (screencast) and a two-phase template renderer. Having spent the time to understand how it works, I've also had my share of ideas on how to improve it (addition of "elif", mathematical operations in variable tags, namespaces). The pony that I've been wanting the most is probably namespaces. There has been talk of adding namespaces to Django templates for quite a while (including a ticket with patches and some various discussions on the mailing list (1, 2 and 3)). For years, this concept has sat dormant due to lack of discussion and interest. No pluggable solution had been offered (as far as I know), so I wrote a couple of templatetags that offer namespacing and other features while retaining backwards compatibility and not requiring a fork of Django. This code is available on Github as django-smart-load-tag.Backwards compatibility Django's policy is to remain backwards compatible, and the template language is certainly no exception. In order to give the "{% load %}" tag namespacing features, it needed to be extended in a way that allows … -
Thread-Safe Object-Oriented Views in Django
An emerging design pattern in Django is the usage of class-based views. Writing views as classes is made possible by Python features that allow classes and objects to behave as callables, just like functions. They can help organize view code and promote reusability by offering a greater level of customization. However, callable objects sometimes have thread safety issues that developers are often not aware of. Update 2/2/11: This post is now mostly irrelevant, because Django will soon solve this problem with the newly-refactored generic view module in Django 1.3, which is due for release this month. Since I wrote this post a year ago, massive arguments over the design of class-based views erupted on the mailing list. It definitely got out of hand, but a lot was learned, and I'm happy with the solution that was committed. I still encourage people to understand how to avoid threading side-effects. I would also suggest reading the new documentation on class-based generic views. The most common approach to class-based views is to create a callable object, a class that has been written with a __call__ method, therefore making instances of the class callable. The view is instantiated either as a module-level variable in … -
Screencast - django-template-repl
Django-template-repl is a unique project aimed at providing debugging tools for the Django template language. I did a screencast to highlight its features.In this video, I describe how to use Django-template-repl's management shell, template tag, and context-capturing features. Please grab the source or simply run: pip install django-template-repl -
Introduction to Surlex Slides from Djangocon 2009
I have uploaded my slides from my lightning talk on Surlex at Djangocon 2009.I have uploaded my slides from my lightning talk on Surlex at Djangocon 2009. Here is the link: http://media.codysoyland.com/pdf/surlex-presentation.pdf. -
Introduction to Surlex
Surlex (Simple URL Expression) is a language for matching and extracting text, similar to regex (regular expression). It works by generating a regular expression from a more concise syntax that is designed to produce easy-to-read url patterns.Installation Surlex is indexed in PyPI, so it can be installed via pip or easy_install: pip install surlex Alternatively, the source code repository is available via git: git clone git://github.com/codysoyland/surlex.git Basic Capturing A capture is performed by enclosing a variable name inside angle brackets: <name> This is equivalent to the following regex: (?P<name>.+) A usage example for matching a blog index view is: /blog/<year>/ This is equivalent to the following regex: /blog/(?P<year>.+)/ This surlex would match the following URLs: /blog/2008/ /blog/2009/ To invoke the capture in our source code we can use the Surlex class or the match function: from surlex import Surlex, match surlex = Surlex('/blog/<year>/') # returns surlex object surlex.match('/blog/2009/') # returns {u'year': '2009'} match('/blog/<year>/', '/blog/2009/') # returns {u'year': '2009'} match('/blog/<year>/<month>/', '/blog/2009/09/') # returns {u'year': '2009', u'month': '09'} Advanced Capturing with Embedded Regex Surlex allows you to insert custom regex strings inside your surlex by postfixing the capture name with the equals sign (=) followed by a regular expression: from surlex import … -
Django Template Debugging Made Easier with django-template-repl
When working with the Django template language, specifically writing template tags or trying out new template tags that are not well documented, it's easy to fall into a testing loop that involves modifying your code, saving the file, causing runserver to restart, which could take some time for large projects, switching to your web browser, hitting reload, and viewing the results. This workflow can be repetitive and unproductive. I decided to improve template interpreter interactivity by writing a REPL for it, and I released the project as django-template-repl, which is freely available on Github and PyPI. I was surprised and happy to see it was well accepted judging from the twitter chatter and github statistics, so I wrote this to better explain how to use it.One of the greatest advantages of Python, Lisp, and other programming languages is the ease of debugging and understanding code behavior provided by REPLs. A REPL, which stands for Read-Eval-Print Loop, is a shell that gives you an interactive command line session with your language interpreter. The two REPLs most Django users should be familiar with are ipython and (i)pdb. These tools are incredibly helpful and really boost the usability of Python. I spend more … -
Tracking Application Response Time with Nginx
Using Nginx to track response times for multiple Django sites served via Apache/mod_wsgi -
We're Hiring!
Lincoln Loop is looking to hire a Python/Django developer. -
Lincoln Loop Development Sprints and Limited Time Discount
Today, we are launching a new offering at Lincoln Loop, development services paid by the sprint. Previously, our typical engagements involved a (sometimes lengthy) discovery, estimation, and bidding process. Lately, however, people have been asking us to jump in with both feet and help them get started immediately. For those people, we think paying for services on a sprint-by-sprint basis will be a great option. As part of our initial promotion for the service, we’re discounting the price 30% for a limited time. -
Using Proxy Models to Customize the Django Admin
Fellow Lincoln Looper, Martin Mahner, posted an excellent write up on how to use proxy models to separate staff and user accounts in Django’s admin. We frequently have a need for this in client projects, but people don’t often consider proxy models for this functionality. Here’s another scenario we came across recently where they came in useful. -
Django 1.1 Testing and Debugging Book Review
A review of Django 1.1 Testing and Debugging by Karen M. Tracey, published by Packt Publishing. -
Installing GeoDjango Dependencies with Homebrew
Installing the GeoDjango dependencies (PostGIS, GEOS, Proj4, and GDAL) on OS X with Homebrew. -
Gondola for Real Estate Launch
I’m pleased to announce that Gondola for Real Estate”, our GeoDjango-backed real estate CMS is publicly accepting new customers. A couple weeks ago, we quietly re-launched gondolacms.com with some details about the platform and what it has to offer, as well as some sites that have been built on it over the last few months. -
Django 1.0 Template Development Book Review
Packt Publishing was nice enough to send us a copy of Django 1.0 Template Development by Scott Newman for review recently. I get most of my technical information via the web, so picking up a technical book was a nice change of pace. This is a well written and enjoyable read for people looking to learn a little more about Django than what is provided in the Django tutorial. -
Custom Filters in the Django Admin
Adding custom data filters to the Django admin interface -
Easy Fabric Deployment, Part 2: Multiple Committers and the Dreaded Umask
In part 1, we showed how we use Fabric to update and deploy Django sites to our development server with a single command. This works great when you only have one developer pushing changes to the server, but what happens when multiple committers need to update the development server? -
Using Haystack to index non-database content
Over on ReadTheDocs, I wanted to build search around the documentation that we're hosting. I chose Haystack and Solr for this, because it's the best way to do search in Django these days. However, I've only ever used Haystack to index content that is in the database. I thought about trying to add all the rendered HTML from the documentation into the database, but that was a non-starter. I ended up adding a ImportedFile model to the database, which would contain the metadata for the HTML file: class ImportedFile(models.Model): project = models.ForeignKey(Project, related_name='imported_files') name = models.CharField(max_length=255) slug = models.SlugField() path = models.CharField(max_length=255) md5 = models.CharField(max_length=255) This allows me to link the SearchIndex in haystack to a model. Then the interesting part is in the Haystack SearchIndex, where I override the prepare_text method, allowing me to read the data in from the filesystem instead of from the database. class ImportedFileIndex(SearchIndex): text = CharField(document=True) author = CharField(model_attr='project__user') project = CharField(model_attr='project__name') title = CharField(model_attr='name') def prepare_text(self, obj): full_path = obj.project.full_html_path to_read = os.path.join(full_path, obj.path.lstrip('/')) try: content = codecs.open(to_read, encoding="utf-8", mode='r').read() return content except IOError: print "%s not found" % full_path site.register(ImportedFile, ImportedFileIndex) This means that I don't have to bloat my database with … -
Handling Django Settings Files
I have seen a lot of talk over the past couple years about how to handle different settings files and databases, synced between production and development. I have happened onto a way of doing it that makes me happy, and figured I would share it with the world. File structure I use a file structure that looks like this: project/ settings/ __init__.py (empty) base.py sqlite.py postgres.py The base.py contains all of the configuration options that are shared among the databases. INSTALLED_APPS, etc. All of the DATABASE settings should be specified in the more-specific files. As well as things that differ by environment, like remote servers, cache settings, cookie domains, and other things. This allows you to run the sqlite settings file, and have it be set to localhost, or whatever your development settings are. Then in production you just run against the postgres settings. A good example of this being used in practice is on Read the Docs. But wait, there's more! manage.py for dev ./manage.py is great for development. It is the easiest way to get started, and it automatically sets up your paths and stuff. With my setup, I actually explicitly set manage.py's settings file to the sqlite … -
Building a Django App Server with Chef: Part 2
Alternate title: Actually doing something useful. Yesterday we covered the basics to getting started with Chef. You should have a remote server configured with chef, and have curl installed! Now lets go ahead and get some useful bits for your Django application. What we'll need So this is going to be based around the way that I set up my servers, so if this is different than you, I'm sorry. However, I think it is a pretty solid way of managing them. A lot of the ideas here are stolen from Travis when he set up the server for Pypants. So lets assemble a list of things we're going to want in order to get a super basic Django configuration running: A user to run our code as and who's home directory we'll store the data. A basic global python ecosystem, including setuptools and pip A virtualenv to store all the project-specific packages and code in A copy of the project that we'll be running Let's get started. The finished code for today is located on github, with the tag blog-post-2. It is a copy of the completed steps, so feel free to peek through that and come back here … -
Building a Django App Server with Chef: Part 4
Alternate title: There's no place like home! This is Part 4, the final part, of my Chef tutorial. Today we're talking about the odds and ends left over to make the server nice to use. You can check out the first 3 parts of the series: Part 1: Chef Beginnings Part 2: Python environment buildout Part 3: Deployment Today's code will be in the git repo under the tag blog-post-4. What we'll need So we have our app server up and running, and ready for traffic. Now we just need to add some other bits around the outside for it to be fully functioning and nice to use. Monitoring with Munin Background tasks with Celery A firewall for security A /etc/hosts file for talking with other nodes A .bash_profile file so that when you shell in you'll have a nice environment Let's get started. Monitoring with Munin For doing monitoring with munin, we're going to need to learn our final Chef concept, which is Templates. You should be pretty familiar with them already, except they use Erb, which is a template language that lets you embed Ruby. We're only going to be configuring the Munin node here. This assumes that …