Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 … -
Introductory Python Programming Sessions in Kuwait
KBSoft will be conducting a series of introductory sessions designed to introduce programmers to new programming tools and to help improve their programming skills. The sessions are: Sunday, Nov 21st 2010 7pm — 9pm: An Introduction to Revision Control with Git. The goal of this session is to introduce how revision control systems can be an indispensable tool to programmers. Git will be the tool of choice for this session and we will go through a number of exercises to show how useful it can be to both individual programmers and programming teams. We will also be introducing a number of best practices for using using Git and help the attendees get more familiar with the system. Tuesday, Nov 23rd 2010 7pm — 9pm: An Introduction to the Python Programming Language. The goal of this session is to introduce python as a general purpose programming language that can be used to solve most problems faced by programmers in Kuwait. There will be a number of exercises to introduce the language syntax and features. In addition to an overview of some of the useful packages in the standard library, language best practices, and how to setup a functional development environment. Thursday, Nov 25th 2010 7pm — … -
Class Based Views and Dry Ravioli
Class based views are very cool. I am starting to clean up an existing project using them, and lots of existing views are turning into declarative code. But it makes me worried about the ravioli effect. -
Django deployment problem
Actually, there are several problems:Upload to the server - usually solved via SCM like git, mercurial, subversion etc – SolvedCopy application files to proper destinations, reboot application - bash/fabric etc. – SolvedCopy user-related media files – usually solved via ignore files, symlinks etc. but there is NO STANDARD or SOLUTION - UnsolvedMigrate database, maybe it's possible to solve it via some migration tool like South but actually I don't know and at this point it's still - UnsolvedFallback to previous version (=any version?) – unsolved and almost impossible to keep data in actual state trough migrations - Unsolved So, what I think about it.Database MigrationsI guess it's possible to solve via South. Another way is to write my own migrations with specific format - SQL with bash/python etc. I will dedicate some time to learn more about migration.Copy user-related media filesI saw something about it in latest version of django. But sometimes I have to work with old releases (1.1.1) of django I need to keep it independent from django - I'll create configuration file which will consist from list of directories where User's data will be stored. Then some playing with symlinks and it will be solved.And, at leastFallback to previous versionThere … -
How to handle variations with Javascript within Satchmo's product template
My goal was to list a set of variations on product page and redirect user to related product page if variation was changed. For example we have two variations:SizeColourAnd values of variatons:Colour: red, black, whiteSize: M (middle), L (large), S (small)So, first of all I display this variations on product page and when user change something (colour or size) then redirect to product with selected colour and size respectively.1. Show dropdowns with variations:{% for option_group in options %}{% trans "Select" %}{{ option_group.name }}{% for choice in option_group.items %} {{ choice.translated_name }}{% if choice.price_change %}{% option_price choice %}{% endif %}{% endfor %}{% endfor %}2. Store all possible variations for javascript to find related product if some of variations was changed on the page:// list of available variations of current product var variations = [ {% for product_variation in product.configurableproduct.productvariation_set.all %}{ 'url': '{{ product_variation.product.get_absolute_url }}', {% for option in product_variation.options.all %} 'group-{{ option.option_group.id }}': '{{ option.value }}'{% if not forloop.last %},{% endif %} {% endfor %} }{% if not forloop.last %},{% endif %}{% endfor %}];3. Add JavaScript code which will handle variations changes: /** * Select & go to variation which have been selected via select box. * This functionality require a …