Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
PyCon 2011 Sprint Report
I love sprints. I've yet to participate in a sprint where I didn't learn something that made a difference in my programming career. Off the top of my head some of the things I've learned include distributed version control, picking the right Python tool, JQuery, SQLAlchemy, Bazaar, Git, Mercurial, the true importance of unittests, and Python's built-in zip function. And the PyCon 2011 sprints were no different.PyCon 2011 was different in that this time I was going to co-lead a project, specifically Django Packages and the hopeful launch of Python Packages.Note: The goal of Python Packages is not to replace PyPI, but rather serve as a resource to find, evaluate, and compare packages used in the every day life of a Python. In my opinion, PyPI should be dedicated to listing and serving packages - anything else (comments, ratings, documentation, etc) just adds complexity to the project and diffuses the focus of their team.It all started with us being the second-to-last in line at the PyCon sprint announcements. At the microphone I forgot to mention a few things so I was worried that our attendance would suck. I tried to take it in good humor, but doubt worried at my … -
Cross-domain quirks in IE8
-
Django howto: Non-conflicting slugs
A while ago I was testing a Django project at work. In the project we had a Django app called Groups. To create a group, you should point the browser to www.domain.tld/group/create/ and to view a group, you had to point your browser to www.domain.tld/group/<group_slug>/. Of course a group slug is unique, so we should never have any conflicts. That is, until I decided to create a group with the slug 'create'.As expected, I was faced by the 'Create a new group'-page when I tried to view my pretty new group. When I swapped some URLs in de Groups app, everybody who tried to create a new group, was served the page of my beautiful group. Everything worked as expected, but still it was considered a bug. This was not the kind of functionality the customer was looking for. For the time being we just let it be (what are the chances the customer would create a group with the slug 'create'?), but the case kept whining in the back of my head.Until today. I decided to tackle the problem. And of course, it was easier than I thought.After entering some smart queries, Google told me that there is something … -
The penguin who owns example.com
Episode 1 of Scared of Rabbits. I feel sad for this poor little bird. Permalink | Leave a comment » -
Setting Up Your Own PyPi Server
-
Setting Up Your Own PyPi Server
Ever had problems with PyPi being unreachable? Dislike dealing with requirement.txt files just to support a git repository? For a low low price of FREE, and an hour of labor, get your very own PyPi server and solve all of your worries!Set up ChishopWe're going to jump right into this one. Sta... -
Celery, Redis and Django
Disclaimer: This is my first English post is a free translation of the original catalan post In previous posts have written about Celery and Django Celery, a system to manage queues and tasks in Python and Django. Celery in its documentation recommends RabbitMQ as message broker, that is, as the application that receives and distributes the tasks that the application sends between the different workers we have configured in our system. Once the worker has done the task it leaves the result (if we have configured to do it) to the results backend, usually it is the same one as the message broker, that is RabbitMQ acts as a message broker and as a result backend. The architecture of Celery is very powerful in the sense it allows us to scale up and down and replace the parts we need to configure the application to our needs. So we could have applications that needs some sort of message or task distribution, but they don't need to deal with the complexity nor the system requirements of RabbitMQ. With Celery we can even use a database as a message broker where could save the results, we can replace the serialization routines, the … -
Celery i Redis
En anteriors apunts he parlat ja de Celery i de Django Celery, un sistema per a la gestió de cues i tasques per Python i Django. Celery a la seva documentació recomana RabbitMQ com a gestor de missatgeria, és a dir, com a aplicació que reb i distribueix les tasques que li envia l'aplicació entre els diferents worker que tenguem al nostre sistema. Una vegada el worker ha realitzat la tasca deixa el resultat (si així ho hem indicat) al contenidor de resultats, que normalment serà el mateix que el broker de missatgeria, és a dir RabbitMQ. L'arquitectura de Celery és molt potent en tant que ens permet escalar cap a baix i substituir peces segons necessitem. Així per aplicacions que necessitin d'un sistema de distribució de tasques però no de la complexitat de RabbitMQ podem utilitzar altres sistemes de notificacions, fins i tot fer servir una base de dades. On es guarden els resultats o com es serialitzen els missatges també es pot canviar. En definitiva, encara que hi hagi una configuració recomanada per a entorns que necessitin de molta potència en el sistema de distribució de tasques i coes, podem personalitzar Celery al nostre gust i a les … -
FOSSGIS Heidelberg, here I come
At Nelen & Schuurmans we're working with geographical information a lot. Most desktop GIS usage in our office is decidedly non-open-source: arcgis. The big commercial "microsoft of GIS". On the (web)server side, everything is decidedly open source. And we use a wide range of open source tools/libraries/data. Some examples: Mapnik. Postgis. Gdal. Openstreetmap. Pyproj. Geodjango. Regarding most of them: we're using it, but our knowledge isn't very deep. At least my knowledge isn't very deep. I can render icons or a geotiff file on a mapnik map just fine, but that's hardly advanced rendering and map typography. And my postgis skills are rudimentary (a drawback partially of using object databases for 8 years with hardly any SQL in sight). Openstreetmap: we use it, but that's it. Time for improvement! So I'm going to the german-language free and open source GIS conference in Heidelberg, Germany. My German is good, at least when listening or reading. (My writing is terribly rusty, as I haven't exercised it in years and I'm unsure about the der/des/dem/den stuff). Three days of talks on a lot of different libraries, use-cases and programs. Just the thing that I need. One of my strengths is absorbing lots of … -
FOSSGIS Heidelberg, here I come
At Nelen & Schuurmans we're working with geographical information a lot. Most desktop GIS usage in our office is decidedly non-open-source: arcgis. The big commercial "microsoft of GIS". On the (web)server side, everything is decidedly open source. And we use a wide range of open source tools/libraries/data. Some examples: Mapnik. Postgis. Gdal. Openstreetmap. Pyproj. Geodjango. Regarding most of them: we're using it, but our knowledge isn't very deep. At least my knowledge isn't very deep. I can render icons or a geotiff file on a mapnik map just fine, but that's hardly advanced rendering and map typography. And my postgis skills are rudimentary (a drawback partially of using object databases for 8 years with hardly any SQL in sight). Openstreetmap: we use it, but that's it. Time for improvement! So I'm going to the german-language free and open source GIS conference in Heidelberg, Germany. My German is good, at least when listening or reading. (My writing is terribly rusty, as I haven't exercised it in years and I'm unsure about the der/des/dem/den stuff). Three days of talks on a lot of different libraries, use-cases and programs. Just the thing that I need. One of my strengths is absorbing lots of … -
Using jQuery templating ICanHaz.js with Django
When working on a Django project with an important part of the user experience based on AJAX, you better use a frontend templating language. The same way Django has a templating language that we use to populate values easing your coder’s life, jQuery has client side alternatives. One of these plugins and my personal favorite is ICanHaz.js created by @HenrikJoreteg. It’s only 4.4 Kb. ICanHaz.js syntax will be very familiar to Django devs, because a variable is defined using double curly brackets {{ variable }}. But I will not enter into details, the project has very easy to follow setup instructions and code examples. When people start using ICanHaz.js in their Django templates, they have a very hard first time trying to get it to work. The problem is simple, Django and ICanHaz.js share the same variable definition, so Django interprets the script templates, breaking them. When I found this out, I looked over the Internet until I found a fix by Eric Florenzano (@ericflo). He coded a templatetag called verbatim, that avoids that Django interprets all content within the block tag. He published it as a gist in Github. You simply have to put this within one of your … -
Django Pattern for Reporting Errors/Messages in Views
I've tried tried to find a decent way to design my Django views so that I can smoothly report errors to users. The errors that I am concerned about are errors that users encounter if they are preforming actions that are typically NOT normally encountered through normal use of the user interface. For example, if users try to directly access a URL of an object that doesn't exist, if they post incorrect values to a URL, or a required value doesn't exist in the user's session. In a utility module, I create a message class that I to store message information. While view processing is taking place, if an error takes place, this class will be used to store the error title, text, and "back" url link. core/utils.pyclass UserMessage(): def __init__(self, title="", text=[], url=None): self.title = title self.text = text if hasattr(text, '__iter__') else [text] self.url = url The view continually checks for the existance of a UserMessage instance. (In the example below, "message" variable is an instance of UserMessage) If an error condition occurs, part of the handing will be to create a new UserMessage, and the view renders an error page using the template defined by message_template_name and … -
Using jQuery templating ICanHaz.js with Django
When working on a Django project with an important part of the user experience based on AJAX, you better use a frontend templating language. The same way Django has a templating language that we use to populate values easing your coder’s life, jQuery has client side alternatives. One of these plugins and my personal favorite is ICanHaz.js created by @HenrikJoreteg. It’s only 4.4 Kb. ICanHaz.js syntax will be very familiar to Django devs, because a variable is defined using double curly brackets {{ variable }}. But I will not enter into details, the project has very easy to follow setup instructions and code examples. When people start using ICanHaz.js in their Django templates, they have a very hard first time trying to get it to work. The problem is simple, Django and ICanHaz.js share the same variable definition, so Django interprets the script templates, breaking them. When I found this out, I looked over the Internet until I found a fix by Eric Florenzano (@ericflo). He coded a templatetag called verbatim, that avoids that Django interprets all content within the block tag. He published it as a gist in Github. You simply have to put this within one of your … -
Python Monads - new approach
-
Python Monads - new approach
I wondered if monads (I probably mean do-syntax) could be implemented in Python. I even googled, but the results1 were not good: in particular, the implementation I found couldn’t work with List monad. The List monad is something I really like (it helps with Project Euler, for example), and I was also able to implement the awesome Probability monad2. So my implementation maybe of some interest. There are other notable things which I liked, for example a lambda-based syntax to use needed (and only needed) bound variables. I must admit that I’m not sure these are exactly monads as in Haskell, but they seem to resemble the do-notation. I like do-notation, call me n00b if you want to. I even managed to use <- as an operator, and don’t ask me how. Okay, take a look: from monads import do, List, Maybe, Probability, mreturn, Var, guard # this is a List monad: l2 = do( Var('a') <- List(lambda: [1, 2, 3]), Var('b') <- List(lambda a: [a + 1, a + 9, a * 40]), Var('c') <- List(lambda a: xrange(a + 5)), guard(lambda b: b < 30), mreturn(lambda b, c: (b, c)) ) print l2.run() # this is Maybe, and it's, … -
AJAX Form Submission in Django
Here is a simple example of using the jQuery javascript framework to hijack and submit a Django form. -
Free Professional Web Development
I'm pleased to announce my immediate availability for some freelance Web development projects. Lately, I've been quite swamped with a very awesome project at my day job. Many things had to be put on hold as a result of that project. However, it looks like the worst is now behind me, and I find myself with much more free time than before! As such, I'm opening the doors to any and all (except full-time, because I love my day job) Web development opportunities. I guarantee absolute satisfaction and reliable, efficient Web sites, and I deliver quickly. All you need to do is provide the requirements for your project in the comments section of this article. I'll pump out at the very least a proof of concept that becomes your property (free of charge), no questions asked. You will not be disappointed. Use this as an opportunity 1) to get free stuff and 2) to test your requirements-gathering/communicating skills. Let the battle begin! -
Announcing Garbaginator!
While working on Packaginator at the PyCon 2011 sprints we discovered some serious issues in the way that Django handles garbage collection. After a huge amount of work, we managed to isolate and fix the problem. This 'fix', as it were, was only possible by doing a very sophisticated 'hack' of critical internal components of the Django Web Application framework. We also discovered that similar issues occurred in other existing Python application frameworks such as Pyramid, Flask, Web.py, Web2Py, Grok, Twisted, Tornado, Google App Engine, and Rails.Since then the Packaginator community has been fiercely debating what we should do with our newly created set of hacks. After a lot of arguments going both ways we've decided to come up with our own application framework and release it to the world under the GPL license.This brand new application framework ignores the lessons learned from all the other Python frameworks and embraces the cutting edge concept of Not-Invented-Here. It focuses less on features and enhancements over existing systems and much, much more on the critical concept of formal Garbage handling.Some of the critical modules include:RubberGloves (for handling dirty objects)Django-GarbaginatorFlask-RecyclingPyramid-GarbaginatorWeb.2.py Garbaginator Bridgerator ('cause people always get Web2Py and web.py confused with each other … -
Subprocess Bug on Windows?
The bug appears to be with 'Fabric' and not subprocess, skip to comments for an explanation I recently looked into using Fabric to automate my Django deployments after reading about the benefits in James Bennett's excellent 'Practical Django Projects'. Whilst following the tutorial on the website I encountered a ... -
Djangocon.eu is gearing up!
2011's djangocon.eu is really gearing up. I like the looks of the fresh website. 6/7/8 June in Amsterdam, here I come! And the sprints afterwards, too, of course. I'm on the conference organizers' mailing list and word is that already half the available tickets are gone! So get yours while they're still available. Early-bird discount pricing is valid till this Friday, btw. Some good things I want to say about the conference location: Amsterdam is incredibly accessible. Every big airline flies to Schiphol airport (Amsterdam's airport). And the TGV/Thalys/ICE high speed trains are there, too. I've seen the conference center itself (pakhuis de zwijger) on the inside two times at a Dutch plone user group day. Good building for a conference, to be sure. I haven't seen the sprint location on the inside, but surely nothing beats a medieval city gate building as a sprint location :-) On the bad side: Amsterdam must by a city of robber barons if those hotels are that expensive. At least the official conference ones are expensive in my opinion. I'm sure there are way cheaper ones (but I don't know which ones). Anyway, I live 45 km away so my company probably won't … -
Djangocon.eu is gearing up!
2011's djangocon.eu is really gearing up. I like the looks of the fresh website. 6/7/8 June in Amsterdam, here I come! And the sprints afterwards, too, of course. I'm on the conference organizers' mailing list and word is that already half the available tickets are gone! So get yours while they're still available. Early-bird discount pricing is valid till this Friday, btw. Some good things I want to say about the conference location: Amsterdam is incredibly accessible. Every big airline flies to Schiphol airport (Amsterdam's airport). And the TGV/Thalys/ICE high speed trains are there, too. I've seen the conference center itself (pakhuis de zwijger) on the inside two times at a Dutch plone user group day. Good building for a conference, to be sure. I haven't seen the sprint location on the inside, but surely nothing beats a medieval city gate building as a sprint location :-) On the bad side: Amsterdam must by a city of robber barons if those hotels are that expensive. At least the official conference ones are expensive in my opinion. I'm sure there are way cheaper ones (but I don't know which ones). Anyway, I live 45 km away so my company probably won't … -
Petites apps … petites mais costaudes
Pour ce mois de mars, je vais parler non pas d'une seule mais de deux petites apps. Deux apps parce que les apps sont tellement petites que l'on va m'accuser de tirer au flanc si je ne parle que de l'une d'entre elles. Mais que d'un autre cotés, ce n'est pas parce qu'elles sont ... -
Announcement: Dates for Django Training, London
After delivering some successful django training for Bangor University in January, I’ve finally got around to setting up my own course. This will be a 2 day introduction to Django for programmers, and will take place on the 17th and 18th May 2011 at City University, London. The course assumes that you can already program [...] -
Django Pattern For Model Permissions
I think I've found an interesting way to set up a permissions system in Django. This system allows you to specify granular permissions on specific object instances and is template friendly. Setup The Permissions InfrastructureFirst, you create an "abstract" Permissions class that models will use as a permissions base class. This base permissions class sets up simple caching for the permissions and creates some common methods to be used by all permissions objects. The current_user represents the logged in that you want to check permissions for a particular object.Notice the use of threadlocals here. If current_user is not supplied in the constructor, the class will try to lookup the current_user from a variable by the threadlocals middleware (see below). Be warned, however, some people don't seem to like the threadlocals approach. To be honest, I'm still trying to evaluate the pluses and minuses, but it sure makes certain things in the templates easier. Comments are welcome. core/permissions.pyfrom core.middleware import threadlocals class Permissions(object): def __init__(self, obj, current_user=False): if not current_user: current_user=threadlocals.get_current_user() if not current_user: current_user = None self.current_user = current_user self.obj = obj self.cache = {} def clear_cache(self, key=None): if key: try: del self.cache[key] except KeyError: pass else: self.cache.clear() def get_current_user(self): … -
Satchmo Status Update
Despite the lack of activity on the satchmo site, there is still plenty of work going on to make Satchmo more stable, feature rich and generally all around better.