Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Tracking changes to fields in Django
A common practice we have used over at Disqus is tracking changes on a model (explicitly) in order to determine if certain actions need to take place when that instance is updated. We tend to use it like "if changed" database triggers. This has been very useful in situations like marking a commen... -
Reactions to "Stupid Template Languages"
My blog post on Stupid Template Languages has had some excellently crafted responses by Armin Ronacher, Mike Bayer, and Steve Holden. I respect and admire each of these developers, and their combined projects have made a real impact on my career. I'm happy that our community is large enough to have a difference of opinion, delighted that our base language of Python allows us the power to play with different options so easily, and hope that we can debate our differences of opinion this year at PyCon. The first round of drinks are on me!Response of Armin Ronacher, creator of Jinja2 and other projectsResponse of Mike Bayer, creator of Mako and SQL AlchemyResponse of Steve Holden, Chairman of the Python Software Foundation and creator of PyCon -
Django forms ChoiceField with dynamic values…
… or how to get a dynamic drop-down list with Django forms The problem: Lets say that you need a form with a drop-down list that have dynamic values. With Django this can be done simple and fast, but if you are new you may get yourself into a trap. In a standard form(with static [...] -
chrisdickinson’s wilson at master – GitHub
chrisdickinson’s wilson. Einen noch vor dem Mittagessen, denn das Framework orientiert sich stark an Django, und da ich ja Django-Fan bin, ist das sicherlich einen eigenen Link wert. -
django-output-validator released
finally got round to cleaning up my Django validator app... -
South 0.7.3 released
I've released South 0.7.3. It's only a bugfix release; the release notes can be found here. -
South 0.7.3 released
I've released South 0.7.3. It's only a bugfix release; the release notes can be found here. -
Finding Out-of-Sync Packages Across Servers with Fabric
We have several servers that are supposed to have the same packages installed, but often get out of sync due over time. To make it easier to find these out-of-sync packages and servers, I wrote a quick fabric script to do the checking for me. The server environment A few things are assumed in this post:  You use pip Your project is installed within a virtualenv None of this will work without pip, as it relies on pip’s freeze command, and it will work really badly if you have multiple projects on the server and no virtualenvs. Starting the fabfile.py You may already be using Fabric for some automation, so you could skip to the next section. We are going to set up our “fabfile,” or list of commands that Fabric will use. Create an empty file named fabfile.py and insert this at the top: from __future__ import with_statement from fabric.api import env, run, settings, hide from fabric.decorators import hosts, runs_once venv = "/home/websites/.virtualenvs/coolsite/" env.user = 'webdev' env.hosts = [ '192.168.1.10', '192.168.1.11', '192.168.1.12', '192.168.1.13', ] This imports the pieces we need, sets the path to find the virtual environment and the connection information. Getting the list of packages pip has a nice command, freeze, that will list all the … -
Porting from App Engine's webapp to django-nonrel
Hey, you may have noticed it already, we've finally finished our top-secret article called Running Pure Django Projects on Google App Engine :). We thank Wesley Chun for his help, expertise and time so we could get the article published on App Engine's articles section. Summarized the article goes through several steps explaining in depth how to port an App Engine webapp app over to django-nonrel with some additional notes on useful Django features. At the end of the article we summarize the advantages of using django-nonrel over other approaches and what awaits you in the future. But enough words, just read the article :) Leave a comment -
URLs on multi-lingual sites: A solution
Let me tell you about two problems: Your site is localized into multiple languages, but the words in its URLs can only be in one language. For example, the URL for the "About Us" page will always be "/about-us/" no matter what language you're viewing the site in. Django's language switching is kind of crappy. You have to post to a view to change the language, and it's hard to expose all the site's translations to search engines for indexing. Ladies and gentlemen, the solution is at hand: Transurlvania! Transurlvania is a small suite of URL-related tools for multi-lingual sites with an incredibly hilarious name. It's up on github here: http://github.com/trapeze/transurlvania Transurlvania has two major components: url translation, and language-in-URL URL Translation URL Translation lets you localize your URLs without a lot of headache. It means the natural language words in your URLs can always be legible to your visitors. How easy is it? Well, here's a regular urlconf module: from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^about-us/$', 'about_us', name='about_us'),) To make that URL translatable, you would transform the module like so: from django.utils.translation import ugettext_noop as _ from transurlvania.defaults import * urlpatterns = patterns('', url(_(r'^about-us/$'), 'about_us', name='about_us'),) Now run make messages and … -
Fuzzy testing with assertNumQueries
When assertNumQueries is overkill... -
Peewee, a lightweight Python ORM
For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. -
App-Centric Django Development Part 2: App Factory
Make it easy Django makes it easy to start an app with the command ./manage.py startapp. However the app template that it creates is very simple and it creates it within the current project. We need to make the process of creating an independent app that easy, with a much better template. To make it that easy, we created a script to ask for information and merge it with an application template. Our script and template is on github and called django-app-skeleton. The App Factory The script to create the new app is a highly modified version of a script from Eric Florenzano. The script asks for a bit of information and then substitutes placeholders within the app template (a directory tree, not a single file) with that information. The substitution is done both within files and on the names of files. There isn’t much information that you need to gather, currently the script requests: Application Name Usually something like “django-somethingorother”. This is the name on PyPI. Package Name Just the “somethingorother” part of the application name. There are places in the default template that want to import the package, and this is the value. Author For the setup.py script, you need an author. Destination Directory Where is the script going … -
Celery: mini tutorial
Configuració del servidor rabbitmq El servidor Rabbitmq és qui rebrà les ordre d'execució de les tasques i les enviarà als workers que han de fer la feina i rebrà el resultats de les operacions de manera que el procés que ha donat l'ordre d'execució de la tasca el pugui fer servir. És important destacar que a l'hora de donar l'ordre d'execució podem decidir si el resultat s'ha de guardar o bé s'ha de descartar. Si el resultat no és necessari (pensem per exemple en l'enviament d'un e-mail) llavors convé marcar la tasca per a que el resultat es descarti. sudo aptitude install rabbitmq-server Els paquets nous següents s'instal·laran: erlang-os-mon{a} erlang-snmp{a} rabbitmq-server 0 paquets a actualitzar, 3 a instal·lar, 0 a suprimir i 5 a no actualitzar. Es necessita obtenir 1398kB d'arxius. Després del desempaquetat s'utilitzaran 3187kB. Esteu segur de voler continuar? [Y/n/?] y Obté:1 http://es.archive.ubuntu.com/ubuntu/ maverick/main erlang-snmp i386 1:13.b.3-dfsg-2ubuntu3 [581kB] Obté:2 http://es.archive.ubuntu.com/ubuntu/ maverick/main erlang-os-mon i386 1:13.b.3-dfsg-2ubuntu3 [77,4kB] Obté:3 http://es.archive.ubuntu.com/ubuntu/ maverick/main rabbitmq-server all 1.8.0-1ubuntu2 [739kB] S'han obtingut 1398kB en 2s (480kB/s) S'estan preconfigurant els paquets... S'està seleccionant el paquet erlang-snmp prèviament no seleccionat. (S'està llegint la base de dades … hi ha 118931 fitxers i directoris instal·lats actualment.) S'està desempaquetant erlang-snmp … -
Peewee, a lightweight Python ORM - Original Post
Edit Rewrote peewee from the ground up Edit, Jul 24, 2011 added support for Postgresql Edit, June 8, 2011 added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when creating rows or grabbing simple lists of objects. Peewee is 77% faster than Django for simple one-row … -
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011 added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011 added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011: added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011: added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011: added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011: added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
Peewee, a lightweight Python ORM - Original Post
Edit I rewrote peewee from the ground up. The query examples in this post are no longer supported. Edit, Jul 24, 2011: added support for Postgresql and MySQL (in addition to SQLite). Edit, June 8, 2011: added support for MySQL For the past month or so I've been working on writing my own ORM in Python. The project grew out of a need for a lightweight persistence layer for use in Flask web apps. As I've grown so familiar with the Django ORM over the past year, many of the ideas in Peewee are analagous to the concepts in Django. My goal from the beginning has been to keep the implementation simple without sacrificing functionality, and to ultimately create something hackable that others might be able to read and contribute to. Weighing in at about 1000 lines of code, Peewee doesn't come close to matching Django's ORM (15K LOC) in terms of API cleanliness or functionality, but it does hit many of the basic use-cases for an app that needs lightweight persistence and querying. This has definitely been one of the most rewarding projects I've worked on! Benchmarks In terms of speed, peewee is generally 25% faster than django when … -
jquerymobile and having design constraints
I’ve been working on this idea/project called Eyes for the past year on and off. Maybe for the past 4 to 6 months I’ve been stymied by what I want the visual representation to look like, struggling with the options … Continue reading → -
Askani crea los modelos de tu aplicación gráficamente
Askani es una interfaz gráfica para generar modelos de Django. Álvaro Mouriño nos cuenta que lleva trabajando algo más de un mes en este proyecto. Askani está desarrollado en javascript y permite definir de forma gráfica modelos, campos, métodos y opciones meta en un estilo bastante similar a UML. Resulta útil para tener una representación más gráfica de los modelos y generar su código automáticamente. -
Django South in a team using SVN
South, the schema and data migration tool for django is really useful. I’ve only started using it myself recently but the benefit is immediate. South creates python files which hold all the information for migrations each time you change the database schema. Each person in a team of developers needs to run these migrations on [...] -
Django South in a team using SVN
South, the schema and data migration tool for django is really useful. I’ve only started using it myself recently but the benefit is immediate. South creates python files which hold all the information for migrations each time you change the database schema. Each person in a team of developers needs to run these migrations on their development database to keep things up to date and working. The question is how does one person in a team know that another has changed the schema? If time has passed then simply asking could get a somewhat hazy response. We use SVN to keep track of code changes amongst the team of developers. SVN is a good place to look to see if migrations were committed. The only thing better than looking in SVN logs for migrations is for SVN to tell us when migrations are committed. So that is what I’ve had a go at doing. Using the SVN pre-commit hook I’ve been able to send emails to those involved in a project each time someone commits code that contains new database migration changes. The first part of this was to create a pre-commit.bat file in the hooks directory of my projects … -
HTML5 offline manifests with django-mediagenerator
This is actually part 3 of our django-mediagenerator Python canvas app series (see part 1 and part 2), but since it has nothing to do with client-side Python we name it differently. In this part you'll see how to make your web app load without an Internet connection. HTML5 supports offline web apps through manifest files. Manifest files First here's some background, so you know what a manifest file is. A manifest file is really simple. In its most basic form it lists the URLs of the files that should be cached. Here's an example.manifest: CACHE MANIFEST /media/main.css /media/main.js The first line is always CACHE MANIFEST. The next lines can list the files that should be cached. In this case we've added the main.css and main.js bundles. Additionally, the main HTML file which includes the manifest is cached, automatically. You can include the manifest in the <html> tag: <html manifest="example.manifest"> When the browser sees this it loads the manifest and adds the current HTML and manifest file and all files listed in the manifest to the cache. The next time you visit the page the browser will try to load the manifest file from your server and compare it to … -
App-Centric Django Development Part 1: Introduction
We’ve created many web sites at The Washington Times, many were just speculative, and most are not around today. In order to prototype a web site quickly, we developed a set of habits that make it easier. I call it “app-centric Django development”. Projects and Apps Django projects and apps are codependent. As a result, most developers write monolithic projects that contain all their apps. It’s easy to do and to understand, but it is not easy for reusing your code. I had a 500-in-1 Electronics set from Radio Shack when I was a kid. I loved it because I could easily create a new device or test different modifications easily. That’s what a Django project is, to me: tt is a place for wiring all the components together. Apps are the individual components; the diodes, transistors, integrated circuits and light bulbs. Our prototyping framework, Calloway, is the direct result of this methodology. The project consists of templates, settings and configuring how different applications work together, and the apps are completely separate. A project may have a few very specific apps that just don’t make sense outside of the web site’s scope, but the vast majority of the apps are installed using pip. Isn’t it …