Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django Site of the Week - Deskography
Seeing how other people work is something that seems to be of interest to most developers. Whether it's because they want to become better workers themselves or because they're somewhat voyeuristic is open to debate - either way, Django-powered website Deskography is a well-designed social desk-sharing website. This week, I spoke to Gustaf Sjöberg of Distrop to find out why they chose Django to power Deskography, and what it's allowed them to do. You can read the interview over at the Django Site of the Week. -
Django Site of the Week - Deskography
Seeing how other people work is something that seems to be of interest to most developers. Whether it's because they want to become better workers themselves or because they're somewhat voyeuristic is open to debate - either way, Django-powered website Deskography is a well-designed social desk-sharing website. This week, I spoke … -
MEDIA_URL and context from processors available in HTTP 500 template
It’s easy to create a custom template for HTTP 500 errors. All you have to do is create a file named 500.html in any of the application’s TEMPLATE_DIRS. But in almost all cases you want to use media in this page. It’s good to have an error page with the same look and feel of [...] -
Better spam defense for Django comments
I've finally found the time to package up an improved version of my comment validation. In addition to the original's simple link count, this version checks if the commenter's IP has been banned or has submitted questionable (non-public) comments in the past, and compares the comment to a series of phrase blacklists. It also includes batch tools in the comments administration pages, to reduce the time you spend banning IPs or deleting spam. -
Enable distutils for a django reusable app
As you might already be aware Pinax move to distutils, this change has been described by James Tauber in this post. Today I have decided to make my feet wet with this approach for a django reusable app. I have been guided by jezdez on #pinax.Before starting I would recommend you to read this page, yes I know, it is a bit long but very interesting. after this reading you will be well prepared to start to work on you django reusable app.I have used one of my project django-geotagging to experiment with this approach. The project can be found on launchpad there. The good news about this approach is that all the major rcs are supported : SVN, BZR, HG, ... If your favorite versionning system is missing there is a good chance that I just forget to mention it. This list is not exhaustive.The core of this approach is a file called setup.py that need to be paced at the root of your repository, most of its argument are self explanatory.This file enable you to setup a complete env in 4 steps :Create a virtual env : virtualenv geotagging_env Move into that env : cd geotagging_env Activate the … -
To FogBugz With Python
A couple of weeks ago, I announced the pyfogbugz project that will, when complete, serve as a python wrapper around the FogBugz API. I have had very little time to spend on it recently so it has not progressed much at all. However, one feature that I have added recently is the ability to use the simple BugzScout interface for submitting bug reports. The one feature about this interface that solves an immediate problem for me is being able to deal with duplicate exception reports. One of my major annoyances with picking up exception reports from an email inbox that FogBugz creates tickets from is that it can't deal with duplicates, so I end up spending a lot of time gardening tickets that are duplicates of each other. BugzScout will solve this problem by automatically appending to a ticket that has an identical title. I find this extremely useful. While the library is not comlete, the BugzScout part of it is usable. To install and use: git clone git://github.com/paltman/pyfogbugz.git cd pyfogbugz pylink pyfogbugz ## See link [1] to Eric Florenzano's post Now in your python script: from pyfogbuz.scout import post_report post_report('title of the report', 'body of the report -- what … -
To FogBugz With Python
A couple of weeks ago, I announced the pyfogbugz project that will, when complete, serve as a python wrapper around the FogBugz API. I have had very little time to spend on it recently so it has not progressed much at all. However, one feature that I have added recently is the ability to use the simple BugzScout interface for submitting bug reports. The one feature about this interface that solves an immediate problem for me is being able to deal with duplicate exception reports. One of my major annoyances with picking up exception reports from an email inbox that FogBugz creates tickets from is that it can't deal with duplicates, so I end up spending a lot of time gardening tickets that are duplicates of each other. BugzScout will solve this problem by automatically appending to a ticket that has an identical title. I find this extremely useful. While the library is not comlete, the BugzScout part of it is usable. To install and use: git clone git://github.com/paltman/pyfogbugz.git cd pyfogbugz pylink pyfogbugz ## See link [1] to Eric Florenzano's post Now in your python script: from pyfogbuz.scout import post_report post_report('title of the report', 'body of the report -- what … -
Django ORM now supports fields references in filters
Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it. Before this update, queryset could be filtered only by absolute values. queryset.filter(field='absolute value') Will generate somthing like this: SELECT * FROM table_name WHERE field = 'absolute value'; Now you [...] -
Full-text searching in Django with PostgreSQL and tsearch2
Recently, I have wanted to improve the searching ability in a number of my projects. I've often added a search box that simply does an icontains filter, which works fine for small sites but doesn't scale due to the inefficiency of matching text with basic SQL queries. The plus side of an icontains filter is that it works on all of Django's database backends (with the exception of SQLite, which works but in a case-sensitive way). All of my projects run on PostgreSQL, an open-source database package that runs beautifully everywhere I've tried it. If you are familiar with MySQL, Postgres shouldn't be a problem for you. When you want to do full-text searching from within your Django projects, you have a few different choices available to you, mostly depending on which database backend you're using: MySQL has built-in fulltext indexing which can be used in Django with some basic ORM extensions. PostgreSQL prior to 8.3 has a 'contrib' module known as tsearch2, which allows full-text indexing within your SQL queries. This is what I am going to detail below. PostgreSQL 8.3 and later has tsearch2 built-in, which is usable in Django if you follow these directions from Barry Pederson … -
Full-text searching in Django with PostgreSQL and tsearch2
Recently, I have wanted to improve the searching ability in a number of my projects. I've often added a search box that simply does an icontains filter, which works fine for small sites but doesn't scale due to the inefficiency of matching text with basic SQL queries. The plus side … -
From WordPress to Django – Part 2
Welcome back. In part 2 I'll be getting to the meat of the issue, which is retrieving the data from an existing Wordpress blog, and feeding the data into my own models. -
Django Site of the Week - ForecastWatch
Eric Floehr is the man behind ForecastWatch and ForecastAdvisor, two Django-powered weather websites that aggregate and analyse weather forecasts to compare their accuracy on an ongoing basis. This week, I spoke to Eric about the history behind his sites, how he handles massive data sets, and his conversion from Ruby on Rails to Django. You can read all about it over at the Django Site of the Week. This weeks' SOTW was delayed by a day due to our Australia Day celebrations on the 26th of January. I figured if they can delay an international Tennis match for fireworks, I could delay this as well :) -
Django Site of the Week - ForecastWatch
Eric Floehr is the man behind ForecastWatch and ForecastAdvisor, two Django-powered weather websites that aggregate and analyse weather forecasts to compare their accuracy on an ongoing basis. This week, I spoke to Eric about the history behind his sites, how he handles massive data sets, and his conversion from Ruby … -
Multi row transaction capabilities
The project in which I wrote a python script to process rows in an Excel spreadsheet interfacing with a MySQLdb and fronted on the web end using django is coming to a close. There is just one more requirement to go. They want rollback capabilities with the ability to completely rollback all actions on a particular excel file if one of the rows in the file buffs up or errors out. This is so that they can correct just that one row in that Excel file then feed the same Excel file to my Python process script without worry about the sanctity of the data of the rest of the rows.This means that I have to somehow implement a multi-row rollback functionality or application level transaction. Python's MySQLdb library supports rollback but only on each transaction. I need a "all or nothing" like functionality. This is something new for me, so I scouted around on google to get some inspiration or to see if someone else had done the same thing. I found this small transaction class by Harald Hoyer at his site. Planning to try out his stuff to see if they can fulfill my requirements. Instinctively, I feel … -
Testing time-based views in Django
There are situations where real time is important in the behaviour of some views. For example, one could write an anti-spam mechanism to prevent robots or ill-intended users to post a form too often and too rapidly. In this article I’ll present a strategy for testing such views. Let’s take a very simple example, in which we’ll let users post messages. The time constraint we’ll set is that users have to wait at least 15 minutes between 2 consecutive postings, otherwise their message will be ignored. I’ll start by giving out the code. First, the model: from django.db import models from django.contrib.auth.models import User class Message(models.Model): user = models.ForeignKey(User, related_name='messages') datetime = models.DateTimeField() message = models.CharField(max_length=100) def __unicode__(self): return self.message Nothing complicated here. Just a simple model to record the user and the time at which the message is posted. Then, we will use a setting to determine the interval of time a user should wait before posting another message (You will see later why using a setting is crucial here). In our example we pick 15 minutes. So, add the following to your settings.py file: MESSAGE_INTERVAL = 60 * 15 # 15 minutes expressed in seconds Now, on to … -
EuroDjangoCon w Pradze
Dzisiaj w internecie pojawiła się informacja że pierwsza w europie konferencja poświęcona django odbędzie się w Pradze w Czechach. Konferencja odbędzie się od 4 do 6 maja 2009 roku. Rejestracja uczestników ma zacząć się 6 lutego. Więcej informacji można znaleźć na stronie konferencji. Zapowiada się ciekawie :) -
OpenOffice.org Losing Viability
OpenOffice.org developer Michael Meeks analyzed 2008 commit data to show that the project is losing steam: decreasing numbers of commits, developers, and companies. He rhetorically asks about how the project is losing technical quality: Why is my bug not fixed ? why is the UI still so unpleasant ? why is performance still poor ? [...] -
Why I'm excited about Python 3
This is a rough transcript, with links, of a 3-minute lightning talk I gave at LCA. It’s obviously not a complete argument; just a 180-second pitch for why the drama about Py3k is all smoke and no fire. I’m excited about porting my code to Python 3, and you should be, too. I’m sure all the Python users here are aware of the recent release of Python 3.0. Python 3. -
Pré-inicializando formulários de um FormWizard
Se você precisa pré-inicializar dados de formulários num FormWizard do Django, você consegue da seguinte forma: my_wizard = MyWizard( [StepOneForm, StepTwoForm], initial={ 1: {field_x: data, field_y: data, ...}, 2: {field_x: data, field_y: data, ...}, ... } ) Certo? Ok, mas e se eu quiser inserir estes dados dinamicamente, de acordo com o usuário logado no site? A forma que eu encontrei de fazer isso foi sobrescrevendo alguns métodos da classe FormWizard. Veja um exemplo: from django.contrib.formtools.wizard import FormWizard class MyWizard(FormWizard): def parse_params(self, request, *args, **kwargs): self.user_data = { 'first_name' = request.user.first_name, 'last_name' = request.user.last_name } def get_form(self, step, data=None): if step == 1: return self.form_list[1](data, prefix=self.prefix_for_step(1), initial=self.user_data) else: super(MyWizard, self).get_form(step, data) ... Não conhece o form wizard do Django? Leia mais a respeito na documentação oficial do utilitário. -
Wsparcie dla agregacji w Django
Ten wpis dotyczy czegoś, co wydarzyło się tydzień temu (tak to jest, jak się nie przegląda na bieżąco rzeczy, które się dzieją w świecie). Otóż do najnowszego kodu Django zostało dodane wsparcie dla agregacji danych (commit: 9742). Polega to na tym, że możemy wyciągnąć z bazy... -
Como usar el poderoso ORM de django en una aplicación de Escritorio
Alguna vez alguien me preguntaba que tan complejo seria usar el poderoso ORM de django en una aplicación de escritorio, lo cual me pareció una cuestión interesante pero debido al trabajo y la procrastinación™ lo dejé a algún lado, en estos días como ando melómano he estado dedicándole mucho tiempo a la musica, por cierto el reproductor que yo uso es Amarok, aunque también decidí probar el mpd, en fin cada cual tiene lo suyo y amarok me parece muy poderoso, probé otros mas como exaile, que intenta ser como amarok pero esta escrito en python con librerías gtk y este muy biche, entonces curioseando y por algunos errores de comportamiento en el amarok, me dio por revisar la estructura de la base de datos, y sinceramente no es lo mejor en modelos E-R, entonces quería ver que tan complejo sería hacer un nuevo reproductor de musica, principalmente que sea un frontend a los más comunes, amarok, banshee, mpd, y demás, incluso con una interfaz web al estilo ampache, pero pues obviamente en python y usando django, entonces empecé a realizar el esquema y de repente se me ocurrio la idea de tambien hacer un cliente de escritorio y volvio … -
Rails versus Django
I attempted to gather my thoughts into some elaborate explanation, delving into the subtleties and intricacies surrounding the question. However, upon reflection my response is a simple one and should be taken lightly. -
Display Children of One-To-Many or Many-To-Many Relationships in your Django Templates
For items you’ve defined in the parent model, such as this: class Project(models.Model): tasks = models.ManyToManyField(Task, blank=True) You use parent.children.all, like so: {% for task in project.tasks.all %} <li>{{ task.title }}</li> {% endfor %} For items defined outside of the parent model with a foreign key pointing back to the parent model, such as this: [...] -
Cambiar permisos de archivos con python
Pues bien la historia comienza así:Estoy desarrollando una aplicación con django para una galeria de arte, la url de la pagina en desarrollo es http://laotraferia.nodo-lab.com que después apuntará a http://www.laotraferia.com y pues probé con django-audioplayer que es un tag para embeber un reproductor de mp3 en la pagina, y no me funcionaba porque por algun motivo extraño al subir el mp3, me quedaba sin permisos de lectura en el servidor, por lo cual decidí que debia cambiarle los permisos cada vez que suban el archivo por lo cual debia reescribir el metodo save en el modelo:def save(self,force_insert=False, force_update=False):super(Audio,self).save(force_insert,force_update)Y allí cambiar los permisos cada vez que guarden el objeto, por lo cual busque en la pagina de python, y encontre el metodo chmod en el modulo os, y primero intenté:>>> import os>>> os.chmod("archivo","777")Al viejo estilo de linux, pero esto me genera un error pues el modo debe ser un entero y no una cadena, hice este cambio y no me genero error pero me cambió los permisos de una forma extraña, luego lei un poco más y es que esto debe hacerse usando otro modulo stat, de la siguiente manera:>>> import os>>> import stat>>> os.chmod("archivo",stat.S_IRUSR+stat.S_IWUSR+stat.S_IRGRP+stat.S_IXGRP)y de esta manera me deja los … -
How to use the same widget as GeoDjango
At the end of this post you will be able to use the same widget than the automatically generated admin interface in geodjango. I spent quite sometimes today to rediscover how to do this. Yes, rediscover because I have already written about this a couple of month ago. My first post on that topic can be read there. Happily "jbronn" on #geodjango gave the solution to me.# Getting an instance so we can generate the map widget; also# getting the geometry field for the model.admin_instance = PointAdmin(Point, admin.site)point_field = Point._meta.get_field('point')# Generating the widget.PointWidget = admin_instance.get_map_widget(point_field)In fact all the complication at the moment there is no static widget that widget you could use in your own form. You have to build them dynamically.I am now going to break down the 3 lines of code.PointAdmin is the ModelAdmin class which is a representation of a model in the admin interface. Here it is an example :from django.contrib.gis import adminfrom geotagging.models import Pointclass PointAdmin(admin.GeoModelAdmin):list_filter = ('content_type','point' )list_display = ('object', 'point', 'content_type', 'object_id')Point in the model we are working on so Point._meta.get_field('point') is accessing the field called point of the Point mode. The code below should help you to understand :class Point(models.Model): """ """ …