Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Python: Virtualenv + pip
"In the Java world there was always a problem with dependencies. All the jars we had to mange by hand – quite awful. Thankfully there is a Maven project which helps us in requirements management. But what about Python? Is there any way to handle necessary libraries? Of course, there is! It is a tandem of virtualenv and pip." by Marcin Swierczynski -
Global Django Permissions
Django has a great solution for web site permissions, it allows the developer to decide how a user can interact with an application based on permissions against models (i.e. database tables). By default a model comes with three permissions, add, change and delete. If these aren’t enough then you can create as many custom model [...] -
Django-qsstats, parce qu’en vrai,on adore tous faire des stats.
Ce mois-ci, j'aurais pu écrire plusieurs django-app du mois. Si j'avais eu le temps. Mais bon, le jour où j'aurais le temps, ça se saura. Du coup, alors que l'horloge tourne et qu'il ne me reste plus qu'un jour et demi pour écrire ma django app du mois et mon polargeek, j'ai décidé d'écrire ... -
Gràcies a tots per venir al creant bits: eines
Actualització: Pujats els documents al dropbox Presentació d'eines Presentació Git Una vegada més, i ja van quatre el creantbits ens ha servit per carregar piles, per trobar-nos amb amics que feia temps que no veiem. Cares conegudes d'altres trobades (des d'aquí moltes gràcies per el detall de les galletes) i un quòrum impressionant. Se nota que en Pau té tirada :) Feia estona que volíem fer una altra trobada d'aquestes. Personalment crec que és molt enriquidora pel que representa d'important per nosaltres veure que hi ha molta més gent que s'interessa pel mateix tipus de coses que nosaltres. Com ja he dit altres vegades això me fa tornar la fe amb la professió. M'hagués agradat poder fer streaming de vídeo, l'hem intentant, però ens ha fallat la connexió. Ja sé que estam a un Parc tecnològic, però ja sabeu com van aquestes coses. A APSL necessitàrem prop de tres mesos en tenir una ADSL i és sols de les normaletes (i cares), res de connexions de 50 Mb que hi ha pels pobles. A veure si la propera vegada hi ha més sort! Com a telonero de Pau he presentat un grapat d'eines que trob d'allò més interessants per fer … -
uWSGI and Django Secure Requests
A colleague and I ran into a frustrating situation this evening when transitioning a site from Apache and mod_wsgi to uWSGI. Django's request.is_secure() wasn't working correctly. After much Googling and shouting at the SSH console, we finally discovered the UWSGI_SCHEME uWSGI parameter. To fix the issue, we edited /etc/nginx/uwsgi_params (which originally comes from nginx/uwsgi_params in the uWSGI tarball) and added an additional param at the bottom: uwsgi_param UWSGI_SCHEME $scheme; This prompts uWSGI to set wsgi.url_scheme to the appropriate value, which Django then detects in the wsgi handler. I'd really love to see this in the documentation on the uWSGI site, or (even better) included by default in the uwsgi_params in the tarball. In the meantime, though, it's a relatively quick and easy fix. Enjoy! -
"Web Scale"
Christophe Pettus: What does [“web scale”] mean? It clearly means something along the lines of, “Can handle lots of transactions per unit time,” but how many? I mean, WordPress with WP-SuperCache is “web scale” if all that is meant is, “Can be used to implement a high volume site,” but I assume those who are touting something as “web scale” are aiming higher than that. Anyone care to offer a quantitative definition of this term? -
In Django, how much faster is it to aggregate?
Being able to do aggregate functions with Django's QuerySet API is really useful. Not because it's difficult to write your own loop but because the summation is then done inside the SQL database. I had this piece of code: t = Decimal('0') for each in some_queryset: t += each.cost Which can be rewritten like this instead: t = qs.aggregate(Sum('cost'))['cost__sum'] For my 6,000+ records in the database the first one takes about 0.7 seconds. The aggregate takes 0.02 seconds. Blimey! That's over 30 fold difference in speed for practically the same thing. Granted, when doing the loop you can do some other stuff such as counting or additional function calls but that difference is quite significant. In my current application those 0.7 seconds isn't really a problem but it quickly becomes when it has to be done over and over for multiple sets. -
In Django, how much faster is it to aggregate?
Being able to do aggregate functions with Django's QuerySet API is really useful. Not because it's difficult to write your own loop but because the summation is then done inside the SQL database. I had this piece of code: t = Decimal('0') for each in some_queryset: t += each.cost Which can be rewritten like this instead: t = qs.aggregate(Sum('cost'))['cost__sum'] For my 6,000+ records in the database the first one takes about 0.7 seconds. The aggregate takes 0.02 seconds. Blimey! That's over 30 fold difference in speed for practically the same thing. Granted, when doing the loop you can do some other stuff such as counting or additional function calls but that difference is quite significant. In my current application those 0.7 seconds isn't really a problem but it quickly becomes when it has to be done over and over for multiple sets. -
In Django, how much faster is it to aggregate?
Being able to do aggregate functions with Django's QuerySet API is really useful. Not because it's difficult to write your own loop but because the summation is then done inside the SQL database. I had this piece of code: t = Decimal('0') for each in some_queryset: t += each.cost Which can be rewritten like this instead: t = qs.aggregate(Sum('cost'))['cost__sum'] For my 6,000+ records in the database the first one takes about 0.7 seconds. The aggregate takes 0.02 seconds. Blimey! That's over 30 fold difference in speed for practically the same thing. Granted, when doing the loop you can do some other stuff such as counting or additional function calls but that difference is quite significant. In my current application those 0.7 seconds isn't really a problem but it quickly becomes when it has to be done over and over for multiple sets. -
In Django, how much faster is it to aggregate?
Being able to do aggregate functions with Django's QuerySet API is really useful. Not because it's difficult to write your own loop but because the summation is then done inside the SQL database. I had this piece of code: t = Decimal('0') for each in some_queryset: t += each.cost Which can be rewritten like this instead: t = qs.aggregate(Sum('cost'))['cost__sum'] For my 6,000+ records in the database the first one takes about 0.7 seconds. The aggregate takes 0.02 seconds. Blimey! That's over 30 fold difference in speed for practically the same thing. Granted, when doing the loop you can do some other stuff such as counting or additional function calls but that difference is quite significant. In my current application those 0.7 seconds isn't really a problem but it quickly becomes when it has to be done over and over for multiple sets. -
Diapositivas del taller Django en Nicaragua
Estas son las diapositivas del taller sobre Django que impartió ayer Adolfo Fitoria en Nicaragua. -
Taller Django!
Hoy se llevó a cabo un el primer taller sobre Django en Nicaragua, la cita se dió en SIMAS y estuve compartiendo con los asistentes sobre como hacer una pequeña aplicación de blog en este framework y la experiencia de SIMAS. … Continue reading → -
Taller Django!
Hoy se llevó a cabo un el primer taller sobre Django en Nicaragua, la cita se dió en SIMAS y estuve compartiendo con los asistentes sobre como hacer una pequeña aplicación de blog en este framework y la experiencia de SIMAS. Acá les dejo la presentación que utilicé: Django View more presentations from Adolfo Fitoria. Hay algunas fotos haciendo click acá -
Bleach, HTML sanitizer and auto-linker
Bleach, HTML sanitizer and auto-linker. HTML sanitisation is notoriously difficult to do correctly, but Bleach (a Python library) looks like an excellent effort. It uses the html5lib parsing library to deal with potentially malformed HTML, uses a whitelist rather than a blacklist and has a neat feature for auto-linking URLs that is aware of the DOM (so it won’t try to auto-link a URL that is already wrapped in a link element). It was written by the Mozilla team for addons.mozilla.org and support.mozilla.org so it should be production ready. -
Django Apps rock
There's been some chat on mailing lists and conferences about the reusability of apps and about how reusable apps suck. So here's in defence of plain old normal non-reusable Django apps. The ones that probably power most of your current awesome Django sites. They rock. Easy to write and build out a site with. Django apps deserve credit for being so rapid to develop and having a very small set of boilerplate and required code (just a models). So before people come up with schemes for making apps reusable, please remember, we've got a great solution for building apps now. Let's not ruin the speed and simplicity of Django app whilst in pursuit of improved reuse. -
Simple MySQL Backup @ Github
A while ago I wrote about a little script I created, for simple backups of MySQL databases and emailing the backups. I found some time to continue on the project and moved it to Github. You can find it as well as documentation there! Simple MySQL Backup @ Github -
Simple MySQL Backup @ Github
A while ago I wrote about a little script I created, for simple backups of MySQL databases and emailing the backups. I found some time to continue on the project and moved it to Github. You can find it as well as documentation there! Simple MySQL Backup @ Github -
Simple MySQL Backup @ Github
A while ago I wrote about a little script I created, for simple backups of MySQL databases and emailing the backups. I found some time to continue on the project and moved it to Github. You can find it as well as documentation there! Simple MySQL Backup @ Github -
Simple MySQL Backup @ Github
A while ago I wrote about a little script I created, for simple backups of MySQL databases and emailing the backups. I found some time to continue on the project and moved it to Github. You can find it as well as documentation there! Simple MySQL Backup @ Github -
When App Engine went wrong
About a month ago Clearwind launched a new site on App Engine. It's a pretty straightforward site for a great client we had. We'd been working on the site for many months a little bit here and there, building out new features as the client requested them. Within a few hours of starting work we had a base site running on App Engine as our test. So that site sat there, quite happily serving out those odd few requests as we added in new features. There was the occasional errors for things like data migrations and testing of new features as we went, but nothing major. And then in September, the site went live - and there was much rejoicing. And then it went down. I did an update (this is a push of the code to the server) and it came back up. And then it went down. And so on. It couldn't stay up for more than about 10 requests or so, sometimes more, sometimes less. I started tweeting, I was pretty upset. The site that had been working fine, just didn't seem to work well. We were getting errors similar to issue 772 and issue 1409. As … -
Cassandra and ElasticSearch backends for Django-nonrel in development
This is a quick update: Rob Vaterlaus has started working on a Cassandra backend and Alberto Paro is working on an ElasticSearch backend for Django-nonrel. The Cassandra backend is still experimental and lacks support for ListField (from djangotoolbox.fields), but overall it already looks very very interesting. This backend comes with experimental secondary indexes support for Cassandra and requires a recent Cassandra 0.7 build. Secondary indexes allow to efficiently query the DB by attributes other than the primary key which makes Cassandra more similar to App Engine and MongoDB than low-level key-value stores. This feature is disabled, by default, though. Currently, without secondary indexes all queries are filtered in memory. The repository contains the installation instructions, so head over and play with the code, if you're fearless. Keep in mind: it's not production ready and it depends on the latest bleeding-edge Cassandra code. Any help with the backend is highly appreciated. The ElasticSearch backend is also in alpha state. Not all unit tests pass, yet, and for now it only supports a simple subset of ElasticSearch. Basically, you can use string operations like __contains, __istartswith, __regex and you can compare integers via __gt, __lt, etc. and you can order results. Currently, … -
Postgres 9 Streaming Replication and Django-Balancer
Over the past couple of weeks I've had the opportunity to dig in to Postgres 9's streaming replication. What I found was a relatively easy way to configure a system for basic replication with very impressive speed. Postgres's streaming replication is an enhancement to the log-shipping warm standby that was available in previous versions. Instead of replaying write-ahead log (WAL) files as they become available on the slave's filesystem, the slave nodes connect directly to the master and stream the log as it generated. This results in extremely fast replication, typically under a second. It can't match the cascading features of Slony, but if you're looking for a simple structure with a master database feeding one or more read-only slaves then Postgres 9 is a great choice. Here's how I got everything working on Ubuntu 10.04. UPDATE: I've changed the NFS details below to squash the user and group IDs and set the anonymous access user and group to the slave server's user and group IDs. This resolves issues where the postgres use has a different ID on the slave server than the master server, so files received from master are owned by the wrong user. Postgres 9 Postgres 9 … -
OCLUG Web Site to Become a Wiki
The Ottawa Canada Linux Users Group board of directors has decided to retire their Django meeting announcement web site and replace it with a plain wiki. But, it's been a great run for close to 4 years: 69 meetings posted, always up-to-date 65 speakers 34 local Linux jobs posted hundreds of members' blog posts aggregated zero maintenance time (removal of old meetings & jobs is automatic) zero reported defects zero down time -
Keeping your logging compatible with Sentry
Something I've noticed while digging around in various libraries, is the inconsistent use of logging. This creates some problems with Sentry, and in the end gives us some very ugly exception logging. Let's take a simple example (we're going to use Celery for this one): if task.eta: try: ... -
Keeping your logging compatible with Sentry
Something I've noticed while digging around in various libraries, is the inconsistent use of logging. This creates some problems with Sentry, and in the end gives us some very ugly exception logging. Let's take a simple example (we're going to use Celery for this one): if task.eta: try: ...