Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Installer Django dans un environnement Python virtuel avec pip, virtualenv et virtualenvwrapper
Ce billet résume les étapes nécessaires pour installer un ou plusieurs environnements de développement Django fonctionnels, portables et faciles à maintenir sous Mac OS X. Même si Django est un framework relativement simple à installer, lorsqu’il s’agit de développer plusieurs projets mettant en œuvre différentes versions de ce dernier ou de librairies tierces nécessaires pour assurer son bon fonctionnement, le casse-tête peut rapidement devenir ingérable si l’on ne prend pas garde à bien isoler le contexte applicatif dans un environnement dédié, isolé du reste du système. Concrètement, imaginons que j’ai deux projets Django : Le projet A utilise Django 1.2-DEV, django_toolbar en version 0.8.3 et Python 2.6 Le projet B utilise Django 1.1 et Pinax en version 0.6 tournant avec Python 2.5 Impossible dans ces conditions d’utiliser une version unique de chacune des librairies installées sur le système (et non, l’utilisation de liens symboliques et de préfixes n’est pas une solution acceptable sur le moyen/long terme). Aussi, découvrant progressivement la richesse de l’écosystème Python, je n’ai pas manqué de m’extasier devant la puissance et la simplicité d’outils tels que pip, virtualenv et virtualenvwrapper pour répondre à ces questions. pip, un installeur de paquet simple et efficace D’aucuns de ceux qui … -
django-site-gen, a tool for automating site creation
Most django sites I create have quite a lot in common. Beyond the handful of files generated by django-admin startproject, my projects all have a database, wsgi file, apache and nginx confs, static media and templates. All these building blocks of a site vary very little from project-to-project. django-site-gen allows you to automate the creation of the stuff that doesn't vary. -
Extending Settings Variables with local_settings.py in Django
I discovered this hacky way to use the local_settings trick to extend and/or override values in the main Django settings file today. Some projects use a "reverse" version of the local_settings trick (which is explained below), whereby the main settings file becomes settings_local.py or something similar, which first imports settings.py, and then extends or overrides [...] -
stackoverflow, stackexchange 2.0 oh my!
The problem It is quite amusing, how the experts-exchange killer stackoverflow.com is becoming something similar. Ever since StackOverflow started, people wanted to make their own sites for similar Q&A types of sites. Various topics could benefit from the similarly formatted Q&A sites. Unfortunately the SO team has not really been very open to open-sourcing it's source code. First they tried to make some bucks from selling it, thanks to the business mind of Joel Spolsky. However not all developers were eager to shell out $130/month for having their own little stackoverflow clone. So then, SO team, figured that they will never make big money by just having 4 paid sites (as that's all they managed to sell I think). What to do, what to do? This is where stackexchange 2.0 comes in. They together with a community (who are mostly developers) will "approve" the topics for the sites they think are worthy, and will host it themselves. Advanges? Ad revenue. Disadvantages? You can't really start your own. Even if your idea is great it may get downvoted by the community. After all - they are a community of developers, not say mechanics. The solution Free Django based Open Source Q&A … -
Idea for a simple task queue
cue is a simple queue abstraction along the lines of the command pattern, and provides django apps with a way to decouple the creation of a request from its execution. -
Damn foreign keys, stealing our jobs and women
Django has support for Generic Foreign Keys, which let you reference one model instance from another, without knowing up-front what that model type is. The classic use for something like this is for a commenting system; you need generic foreign keys – or something like them – because you wouldn't want a commenting system that only worked with a single model. If you have ever used generic foreign keys in Django, you will know that it is not quite transparent to the developer; a little effort is required to manage the various content types. I'll present here an alternative method to achieve this late binding of foreign keys that doesn't require storing the type of the object (as generic foreign keys do) and is completely transparent to the developer. I'm sure I'm not the first to think of this method, but I haven't yet seen it used in other Django projects. Rather than store the type of object in a separate field, we can create a new model for each foreign key type we want to reference. For example; lets say we have a Rating model, and we want to rate Articles and Images – we could do this by … -
Damn foreign keys, stealing our jobs and women
Django has support for Generic Foreign Keys, which let you reference one model instance from another, without knowing up-front what that model type is. The classic use for something like this is for a commenting system; you need generic foreign keys – or something like them – because you wouldn't want a commenting system that only worked with a single model. If you have ever used generic foreign keys in Django, you will know that it is not quite transparent to the developer; a little effort is required to manage the various content types. I'll present here an alternative method to achieve this late binding of foreign keys that doesn't require storing the type of the object (as generic foreign keys do) and is completely transparent to the developer. I'm sure I'm not the first to think of this method, but I haven't yet seen it used in other Django projects. Rather than store the type of object in a separate field, we can create a new model for each foreign key type we want to reference. For example; lets say we have a Rating model, and we want to rate Articles and Images – we could do this by … -
Damn foreign keys, stealing our jobs and women
Django has support for Generic Foreign Keys, which let you reference one model instance from another, without knowing up-front what that model type is. The classic use for something like this is for a commenting system; you need generic foreign keys – or something like them – because you wouldn't want a commenting system that only worked with a single model. If you have ever used generic foreign keys in Django, you will know that it is not quite transparent to the developer; a little effort is required to manage the various content types. I'll present here an alternative method to achieve this late binding of foreign keys that doesn't require storing the type of the object (as generic foreign keys do) and is completely transparent to the developer. I'm sure I'm not the first to think of this method, but I haven't yet seen it used in other Django projects. Rather than store the type of object in a separate field, we can create a new model for each foreign key type we want to reference. For example; lets say we have a Rating model, and we want to rate Articles and Images – we could do this by … -
The Mess Django’s In?
In the Mock It! blog, Malthe Borch writes that Django’s innards are a disaster. The comments are as good as the article. Money quote: [If you] take a peek under the hood, your impression of Django will change dramatically: The code is awful. [Django's] got a terrific story if you’re willing to drink the kool-aid [...] -
My Idea Of The Django Blogging App™
I am not going to talk about yet another Django-based blogging engine in this post. There are a number of blogging apps which try to be like turn-key solutions, like a WordPress blog. I have skimmed through the code of many such apps, but haven’t used one yet. Some of them are really high quality [...] -
Optimizing Django: tricks for faster page loads
By reducing the file size of your CSS, JavaScript and images, as well as the number of unnecessary browser requests made to your site, load time of your applications pages can be drastically reduced, not to mention the load on your server. Yahoo have created a list of the 35 best practices to speed up your website, a recommended read for any web developer. I wanted to summarize a few I recently implemented in a Django application. In a nutshell: Serve compressed static media files. This one is obvious, the smaller the file size, the quicker it is to download. Once a browser has already downloaded the static media, it shouldn't have to download it again. This is what actually happens, as the server will respond with 304 Not Modified, which means that the cached file is still up-to-date. However, the HTTP request is still sent. This is unnecessary and should be avoided by setting the HTTP Expire header to a date in the future. When files are updated, you need to give them a new URL so the browser will request them. This is referred to as versioning. A common scheme is to use the modification time/date of the … -
Optimizing Django: tricks for faster page loads
By reducing the file size of your CSS, JavaScript and images, as well as the number of unnecessary browser requests made to your site, load time of your applications pages can be drastically reduced, not to mention the load on your server. Yahoo have created a list of the 35 best practices to speed up your website, a recommended read for any web developer. I wanted to summarize a few I recently implemented in a Django application. In a nutshell: Serve compressed static media files. This one is obvious, the smaller the file size, the quicker it is to download. Once a browser has already downloaded the static media, it shouldn't have to download it again. This is what actually happens, as the server will respond with 304 Not Modified, which means that the cached file is still up-to-date. However, the HTTP request is still sent. This is unnecessary and should be avoided by setting the HTTP Expire header to a date in the future. When files are updated, you need to give them a new URL so the browser will request them. This is referred to as versioning. A common scheme is to use the modification time/date of the … -
Optimizing Django: tricks for faster page loads
By reducing the file size of your CSS, JavaScript and images, as well as the number of unnecessary browser requests made to your site, load time of your applications pages can be drastically reduced, not to mention the load on your server. Yahoo have created a list of the 35 best practices to speed up your website, a recommended read for any web developer. I wanted to summarize a few I recently implemented in a Django application. In a nutshell: Serve compressed static media files. This one is obvious, the smaller the file size, the quicker it is to download. Once a browser has already downloaded the static media, it shouldn't have to download it again. This is what actually happens, as the server will respond with 304 Not Modified, which means that the cached file is still up-to-date. However, the HTTP request is still sent. This is unnecessary and should be avoided by setting the HTTP Expire header to a date in the future. When files are updated, you need to give them a new URL so the browser will request them. This is referred to as versioning. A common scheme is to use the modification time/date of the … -
Announcing django-audit
As part of some work at 2degrees on ensuring an audit trail for our Django models, we have been working on a project to add under-the-hood auditing to the Django Model class.We've published an early alpha of this code on launchpad, and hope to have a final release for this package around the end of May to coincide with the deployment of our internal code.If you can't wait for the documentation, then checkout the code and have a read of the source. Otherwise documentation will be coming along shortly. -
GSOC 2010 – I’m updating the Django Test Suite
I’ve been accepted to work on Django’s Test Suite during the Google Summer of Code this year. I’ll be working to improve the runtime and uniformity of the test suite, mainly by converting existing doc tests to unit tests. This isn’t particularly glamorous, but it should be a chance to get intimately familiar with the [...] -
Primeiro projeto com Python, Django e MongoDB
Estou desde o começo deste ano acompanhando o hype dos bancos de dados orientados a documento, também chamado de NoSQL (embora não goste muito deste termo). Como bom curioso, resolvi testar algumas variações como o CouchDB e MongoDB, onde acabei me identificando mais com o segundo. Gostei da praticidade e rapidez em fazer as coisas com ele, também a performance me chamou muito a atenção, tem uma boa biblioteca Python e a documentação é muito objetiva, com exemplos de uso. Esses pontos foram decisivos para a escolha. Com um banco de dados orientado a documentos, não existe a necessidade de criar o modelo das tabelas, basta definir um documento (estilo JSON) e inserir na base. Esses documentos podem ter campos a mais ou a menos dependendo da necessidade e tudo pode ser indexado e encontrado facilmente. Estou trabalhando em um projeto onde é necessário indexar uma grande quantidade de informações e documentos. O problema é que muitos documentos não seguem um padrão e existe a necessidade de estar alimentando a base a todo instante com novas informações. Já desenvolvi modelos de busca neste estilo utilizando o Xapian, que é uma excelente ferramenta. Porém a performance fica bastante prejudicada quando a … -
Django Model Templates (sans-Denormalisation)
I came across an interesting problem recently, while trying to model the structure of a university course in Django. The model needed to represent the notion of a university module, which can be taught over a number of semesters and/or years, by different people, and with different students each time round. Some information remained common [...] -
Official nonrel/NoSQL support in Google Summer of Code!
This is great news for Django developers who want to use non-relational DBs: Alex Gaynor got accepted for adding non-relational DB support to Django's ORM during Google Summer of Code! This means that we now have to make sure that the ORM changes are flexible enough to build a common API for all nonrel DBs, so code can be reused everywhere without any modifications (or, at least between DBs with similar capabilities). Once we have official nonrel support in Django we can move on to the next phase of Django-nonrel: building an indexing layer which supports denormalization and many other features that go beyond the DB's native capabilities and which you'd normally implement by hand. This topic has been discussed in the recent DjangoDose NoSQL panel and you surely noticed how controversial it is. Well, we don't have to decide which solution is the best one - both have their pros and cons. Instead, our planned Django-nonrel indexing layer can be an optional package (outside of Django core) that you can use on top of the low-level backend if you want more productivity, at the cost of having to understand what the technical limitations behind this method are (they're the … -
De retour de Djangocong
Les rencontres Django francophones 2010, tenues à Marseille, viennent de s’achever. David Larlet m’ayant invité à y participer, j’y ai présenté une conférence “Django pour les développeurs Symfony” puisqu’étant moi-meme utilisateur des deux frameworks. Vous trouverez les slides de la présentation sur slideshare, ou sur la page dédiée à Django sur le site d’Akei. N’hésitez pas à faire vos retours en commentaire. -
Our New Open-source Projects
Apart from GLAMkit, we have rarely mentioned our open-source projects. I wanted to quickly show three which were recently open-sourced by IxC contractors in the course of their work for us: django-nose-lite, by howthebodyworks - a lightweight nosetests runner for Django projects. My favourite is to run it with —pdb, which drops into pdb on test failures. django-smuggler, by semente is fairly simple. It adds a button to Django’s admin interface which dumps and loads fixtures to your (local) computer - for superusers only. django-hashtags, also by semente, converts Twitter-esque #hashtags in text fields into a link to search for items with those hashtags - recent tweets included. Feel free, of course, to reuse, fork and contribute changes. There are more releases in the works. -
A handful of snippets
A collection of a few snippets I've made use of recently. -
MyUni and Django 1.2
MyUni is hailed as my "latest venture" on the front page of my website. In fact, it was conceived early last year, when I was in my first year at Nottingham University, by Rob Miles and Ben Jenkinson. We were only just starting to get to grips with this new fad, called Django. The project [...] -
Moving away from DC
Way back in 1969, when I was about a year and a half old, my family moved to Laurel, Maryland, which is about 20 miles north of Washington, DC. Since then, I've lived in central Maryland, Washington, and Northern Virginia. I enjoyed my friends and family, and the things that I've done.Yet I always wanted to see the rest of our world, try new things, explore new horizons. Breathe different air, if you will. My ideal existence would be to live in a lot of different places, living six months for a time in place to place so I can get a good experience of the planet.Not long ago conditions came together that made it feasible for me to do all this. My house is sold, my son is 18, I don't currently own any furniture, and I have a job that allows/encourages for telecommuting (and that is because of Python and Django). So on May 5th I'm moving to Los Angeles, California for a short term stay. I'm there to hang out with a certain artist/developer and to go on a vacation that I've wanted to do for many months. More details on this move in another post.In early … -
Fashiolista.com – Django at The Next Web – part 1
Fashiolista.com is launching in 7 days and has already been getting quite some attention. Techcrunch: 25 startups that will be shaping the next web. For Fashiolista we’ve been able to utilize a great deal of best practises learned in previous Django based sites. More on this topic later. For now I’m wondering if there are many other Django fans attending the next web conference. The conference itself should be very interesting. Definitely looking forward to Werner Vogels and Joe Stump. The later seems to be running Django for SimpleGeo. Share and Enjoy: -
Vim autocomplete, Django and virtualenv
One of the features I quite missed when I first moved from Komodo to Textmate as my main editor was autocompletion. Although I didn't use it very much, it was occasionally useful to be reminded of the methods available on a class, without having to look up the documentation or open the source module. Now I've moved to vim, which has its own version of autocomplete: omnicompletion. This is activated by pressing Ctrl-X Ctrl-O in insert mode after typing the name of a class or instance, and displays a nice drop-down menu with all the available members of that object. The Python plugins which come with vim allow this function to not only complete items from the standard library, but also to parse your own files which are open in the editor, reading the modules you import and adding those elements to the completion dictionaries. However, this wasn't working for me in my Django projects. After a lot of investigation, I found that this was down to three issues. The first two of these related to the fact that I was working within a virtualenv. Despite the fact that I was starting MacVim after activating the virtual environment, the specific …