Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Tutorial: Custom Feed Generation using Django Syndication Feed Framework 1.2 and later
Sometime back, when I was writing an application for my company, I took the task to implement generation of feeds. My initial choice was obviously Django's own Syndication Feed Framework which probably came with some changes in 1.2 version. Initially it looked like a piece of cake. But, for the Atom feeds the client wanted to have something which required a fair bit of customization. The current Django documentation turned out to be falling short of what I really needed, and a proper concrete example seemed to be missing. After spending a day with the given things, snippet examples, django core for the feed framework, and some help from google, I was finally able to get what was desired. So, for the rest of the post I would like to take you through the "missing tutorial" for Custom Feed Generation using Django Syndication Feed Framework 1.2 and later. This tutorial is basically for people who wants to use the framework with their own customizations coming in. For example, adding a new tag element to the item, or introducing some pre-processing checks, etc. It is assumed that you have already gone through the official documentation. Rather than giving a step by … -
Tutorial: Custom Feed Generation using Django Syndication Feed Framework 1.2 and later
Sometime back, when I was writing an application for my company, I took the task to implement generation of feeds. My initial choice was obviously Django's own Syndication Feed Framework which probably came with some changes in 1.2 version. Initially it looked like a piece of cake. But, for the Atom feeds the client wanted to have something which required a fair bit of customization. The current Django documentation turned out to be falling short of what I really needed, and a proper concrete example seemed to be missing. After spending a day with the given things, snippet examples, django core for the feed framework, and some help from google, I was finally able to get what was desired. So, for the rest of the post I would like to take you through the "missing tutorial" for Custom Feed Generation using Django Syndication Feed Framework 1.2 and later. This tutorial is basically for people who wants to use the framework with their own customizations coming in. For example, adding a new tag element to the item, or introducing some pre-processing checks, etc. It is assumed that you have already gone through the official documentation. Rather than giving a step by … -
Getting piston forms to play nicely with JSON
A commonly used tool by Djangonauts is django-piston, which is designed to make building a REST API easier. It even works with Django forms to provide easily written PUT/POST validation, which should be pretty darn nice. Unfortunately, if you go with django-piston forms validation it doesn't accomodate the JSON (or XML or YAML) requests and if validation fails it responds in HTML. Even more unfortunate, making validation accept and return JSON with PUT/POST requests is not documented.While one could argue that it is documented in the django-piston docstrings, in my opinion that is not sufficient.Fortunately while working on a project for Revolution Systems we worked out a solution:"""myapi/resource.py author: Daniel Greenfeld license: BSDThis assumes your API accepts JSON only."""import jsonfrom piston.decorator import decoratorfrom piston.resource import Resourcefrom piston.utils import rc, FormValidationErrordef validate(v_form, operation='POST'): """ This fetches the submitted data for the form from request.data because we always expect JSON data It is otherwise a copy of piston.util.validate. """ @decorator def wrap(f, self, request, *a, **kwa): # Assume that the JSON response is in request.data # Probably want to do a getattr(request, data, None) # and raise an exception if data is not found form = v_form(request.data) if form.is_valid(): setattr(request, 'form', form) return f(self, … -
Managing per-field indexes on App Engine
An annoying problem when trying to reuse an existing Django app is that some apps use TextField instead of CharField and still want to filter on that field. On App Engine TextField is not indexed and thus can't be filtered against. One app which has this problem is django-openid-auth. Previously, you had to modify the model source code directly and replace TextField with CharField where necessary. However, this is not a good solution because whenever you update the code you have to apply the patch, again. Now, djangoappengine provides a solution which allows you to configure indexes for individual fields without changing the models. By decoupling DB-specific indexes from the model definition we simplify maintenance and increase code portability. Example Let's see how we can get django-openid-auth to work correctly without modifying the app's source code. First, you need to create a module which defines the indexing settings. Let's call it "gae_openid_settings.py": from django_openid_auth.models import Association, UserOpenID FIELD_INDEXES = { Association: {'indexed': ['server_url', 'assoc_type']}, UserOpenID: {'indexed': ['claimed_id']}, } Then, in your settings.py you have to specify the list of gae settings modules: GAE_SETTINGS_MODULES = ( 'gae_openid_settings', ) That's it. Now the server_url, assoc_type, and claimed_id TextFields will behave like CharField … -
Atom feed supported
Scratch Blog now also supports Atom feed as specified in http://www.atomenabled.org/developers/syndication/atom-format-spec.php. This is also implemented using the Django Syndication Feeds Framework 1.2 and later. Some customizations have been used to let the framework generate the feed as per our requirement. -
Atom feed supported
Scratch Blog now also supports Atom feed as specified in http://www.atomenabled.org/developers/syndication/atom-format-spec.php. This is also implemented using the Django Syndication Feeds Framework 1.2 and later. Some customizations have been used to let the framework generate the feed as per our requirement. -
Creating an Alphabetical Filter in Django's Admin
Update: See the new blog post about the updated version. Django’s admin includes a great date hierarchy filter for navigating date data in a model. I’ve come into a few situations where it would be nice to have a similar filter for the alphabet. If you are managing hundreds or hundreds of thousands of names, tags or other alphabetical data, it would be nice to filter things alphabetically. Using the date hierarchy as the template, I’ve implemented an alphabetical filter for the admin. The code and sample project is available on github and will soon be on PyPi. Implementing the Alphabet Filter There are three parts: The admin change_list.html template The alphabet filter template tag The alphabet.html template The change_list.html Template This template is easy to override on a per-model basis or per-application basis simply by where you save it. The current change_list.html template cannot be installed on a project wide basis as it extends admin/change_list.html and doing so leads to an infinite loop. Per Model: <application>/templates/admin/<application>/<model>/change_list.html or <project>/templates/admin/<application>/<model>/change_list.html Per Application: <application>/templates/admin/<application>/change_list.html or <project>/templates/admin/<application>/change_list.html Project Wide: Would have to copy contrib/admin/templates/admin/change_list.html to <project>/templates/admin/change_list.html and apply the appropriate changes. The template extends admin/change_list.html adding in some extra styling and overriding the date_hierarchy block. {% extends "admin/change_list.html" %} {% load admin_list alphafilter %} … -
Django Documentation for the iPhone
A better way of adding the Django documentation to your iPhone, iPod Touch or other mobile browser. -
Mayflower Barcamp - awesome!
Mayflower had invited me to join their Barcamp last weekend - and it was awesome. Thank you a lot!!! We had been a crowd of about 40 people all hacking all day long until deep at night, it was a great atmosphere and some very interesting projects had been made. ... -
Installing MySQLdb on Leopard
Thanks to Arne we got it done pretty quickly. -
Django’s dev server and UTF-8
From time to time I got this UnicodeEncodeError, but I had done all the things (sitecustomize.py, some more) right in order to configure the system in UTF-8. I thought. I did the usual ./manage runserver and since I assumed that on my Mac everything is already properly configured ... -
Customize admin for User model
Before django 1.0 I don't remember that there was a way to customize how the admin renders the User overview. Fortunately 1.0 does allow it. It took me a bit to figure out. After searching the web and the django docs I didn't find it right away, so I tried the ... -
dojo.beer(2)
We from uxebu have organized the second dojo.beer and are happy to have won Mayflower to jump in sponsoring the location here in Munich, Germany. On friday the 5th december we will warm up with some dinner and some beer in some place here in Munich. The real thing will ... -
The timeline for dojo meetup Berlin
The plan for May 31st, 2008 is 15:00 meet at Weltzeituhr, as mentioned on upcoming, more info and a pic see here. When you are on Alexanderplatz you should find this clock pretty quickly. 19:00 - 22:00 we will be in Las Olas and afterwards go to some bar, club, whatever we ... -
Django/Dojo Stammtisch in Berlin
For the second time Django enthusiasts are meeting in Berlin on Wednesday, the 15th April, 2009 at 19:30. Find all the details here. And since I will be in Berlin this time, I just simply redeclare this to "Django/Dojo Stammtisch" instead of just "Django Stammtisch" :-). I hope all the ... -
JavaScript: Sort object by a value
Actually the headline is not really what I want to say :-). But I don't know any better yet. I just want to write down how I solved sorting the following: >>> var maxSpeed = {car:300, bike:60, motorbike:200, airplane:1000, helicopter:400, rocket:8*60*60} This is a list of vehicles with their (approx.) ... -
dojo+django = dojango (just released)
Finally we have released dojango. Well, to be honest it's mostly Tobi's work that dojango rocks as it does! Big thanks! So if you are still looking for the right JavaScript toolkit to go with django then you are at the end of your search now. Use dojango! Dojango s a reusable ... -
Adobe Air Tour Europe stopped in Munich
Fortunately Tobias found out one day before that Adobe was touring with Air and coming to Munich. Adobe really had provided everything, from breakfast, drinks, lunch too I guess (we weren't there) and beer afterwards (that we didn't miss). It was really impressive. The talks were very Air focused, I ... -
Show a Custom 403 Forbidden Error Page in Django
Creating a custom 404 Page Not Found error page is so easy in Django (all you do is put your own template named “404.html” at the root of your templates directory) that I naturally assumed doing the same for a 403 Forbidden error page would be just as easy. Unfortunately it is not. After searching [...] -
MapOSMatic
MapOSMatic. Clever service built on top of OpenStreetMap, which renders double sided city maps with a map and grid on one size and an A-Z street name index on the other. Runs on top of Mapnik, PostGIS and Cairo, with a few thousand additional lines of Python and Django. -
Sorteamos "La guía definitiva de Django"
Hace días avisamos de que íbamos a sortear una de las copias de "La guía definitiva de Django" que Anaya Multimedia nos envió. ¡Y hoy nos ponemos a ello! Para entrar en el sorteo sólo tenéis que escribir un comentario en esta entrada mediante el formulario que encontraréis al final de la página explicando sobre qué os gustaría que escribiéramos en el blog de Django.es. Obviamente debe tratarse de algún tema relacionado con Django. -
I want to talk to Jython and Iron Python developers
I want to ask some questions of the Jython and Iron Python communities. I'm primarily looking for efforts that can go into publishable case studies. Experience in use of Django in the Jython and Iron Python environments is also very much desired. Please use my email address which is obfuscated below and can be decoded by simply running the code in a python shell:''.join([chr(x) for x in [112, 121, 100, 97, 110, 110, 121, 64, 103, 109, 97, 105, 108, 46, 99, 111, 109]]) -
Probando los sabores de localflavor
Django incluye la aplicación django.contrib.localflavor que agrupa campos de formulario y widgets específicos para distintos países. Vamos a ver lo que podemos hacer con el "local flavor" para España. -
Hosting Django static images with Amazon Cloudfront (CDN) using django-static
About a month ago I add a new feature to django-static that makes it possible to define a function that all files of django-static goes through. First of all a quick recap. django-static is a Django plugin that you use from your templates to reference static media. django-static takes care of giving the file the optimum name for static serving and if applicable compresses the file by trimming all whitespace and what not. For more info, see The awesomest way possible to serve your static stuff in Django with Nginx The new, popular, kid on the block for CDN (Content Delivery Network) is Amazon Cloudfront. It's a service sitting on top of the already proven Amazon S3 service which is a cloud file storage solution. What a CDN does is that it registers a domain for your resources such that with some DNS tricks, users of this resource URL download it from the geographically nearest server. So if you live in Sweden you might download myholiday.jpg from a server in Frankfurk and if you live in North Carolina, USA you might download the very same picture from Virgina, USA. That assures the that the distance to the resource is minimized. … -
Hosting Django static images with Amazon Cloudfront (CDN) using django-static
About a month ago I add a new feature to django-static that makes it possible to define a function that all files of django-static goes through. First of all a quick recap. django-static is a Django plugin that you use from your templates to reference static media. django-static takes care of giving the file the optimum name for static serving and if applicable compresses the file by trimming all whitespace and what not. For more info, see The awesomest way possible to serve your static stuff in Django with Nginx The new, popular, kid on the block for CDN (Content Delivery Network) is Amazon Cloudfront. It's a service sitting on top of the already proven Amazon S3 service which is a cloud file storage solution. What a CDN does is that it registers a domain for your resources such that with some DNS tricks, users of this resource URL download it from the geographically nearest server. So if you live in Sweden you might download myholiday.jpg from a server in Frankfurk and if you live in North Carolina, USA you might download the very same picture from Virgina, USA. That assures the that the distance to the resource is minimized. …