Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Google App Engine
Wow! Google just announced Google App Engine which will allow users to host their python applications on their server infrastructure similar to Amazon's EC2 services, but in a more straight-forward manner. The timing is perfect, as I am in the middle of evaluating virtualized hosting for our newspaper websites. The fact that they've started with python and django as the core runtime is huge. That said, all is not perfect. As Eric and I read more into this, there appear to be some serious limitations. The google model library seems simplistic, even by django standards ( don't ask the sqlalchemy folk to weigh in on this one ). Eric has a more complete write-up on this. Pricing is yet to be set. I hope it is reasonable. For my own personal uses, EC2 turned out to be quite expensive compared to the great service I get from SliceHost. I wonder how this will effect all of the smaller hosting companies out there. Free accounts were given to the first 10k users to sign up, and I was pitifully slow in doing so, so I am on the waiting list. Does anyone know if the next wave of accounts will be … -
Google App Engine: the first look
Yesterday Google announced its new offering: Google App Engine. These are my random notes I did yesterday when I studied the new service. Google didn’t go the same way as Amazon with its AWS. The former offers a form of shared hosting (think “distributed WebFaction”), while the latter offers a virtualized environment (think “distributed SliceHost”). So basically we are talking about more high-level approach to web applications, which is easy even for novices. On the other hand AWS is more flexible and more enterprise-y. In order to scale, you have to virtualize. In order to virtualize, some actions should be restricted. Google App Engine provides a sandbox on the language level. Only one language is supported at the moment: Python. And guess what? Django is everywhere! For virtualization reasons only the pure Python is supported and a subset of the Python standard library. You can bundle any pure Python modules with your application. Three third-party libraries are available out-of-the-box: Django 0.96.1, WebOb 0.9, and PyYAML 3.05. But fret not, you can bundle a framework of your choice with your application and run it too, even a custom version of Django — basically anything that supports WSGI. I suspect that other … -
Google Launches App Engine
Google just launched a new platform called App Engine. Basically it allows you to run your web application on Google’s servers using much of their main infrastructure such as BigTable and GFS. The best part is, you write App Engine apps in Python and they include Django out of the box! Mike Arrington has a video of Guido Van [...] -
Django and the Google AppEngine
I’m sure that anyone into Django will either see or hear about this before they catch my blog post, but it’s too neat a story not to write about a comment on. Tonight, Google released AppEngine – an elastic computing … Continue reading → -
Using decorators in Django views to assert the DRY principle
A lot of people finds decorates to be pure magic. I will try to de-mystify some of the magic around them, and show how we can use them to clean up the views in a Django application. I will start by giving a short introduction to decorators and closures and then afterwards show how we can use this in Django to, as the title says, assert the DRY (dont repeat yourself) principle So, what is a decorator? A decorator is a closure. That is, a set of local variables (an evironment) and some code (in this case, a function) to be executed in this environment. A small example of a simple closure: def adder(n): def inner(m): return n + m return inner When a call to adder is made, a new function is returned. This function has one local variable (n) already and takes another one as an argument (m). An example use could be: >>> add_five = adder(5) >>> add_five(37) 42 In Python, it's very popular to say that everything is an object and can be tangled with. This is also the case of functions. When defining a function, all you really do is defining a variable pointing to … -
Internet lifestream with Django
My goal was to archive and display my internet lifestream. My first approach was writing a client for each API of the social networks that I'm in. This turned out to be a complete waste of time and effort. All that I needed after all was a FriendFeed account that would centralize all my feeds. Archiving and displaying your entries with Django is quite simple. First of all, you need to download the Python FriendFeed API client. Then start a new application in your project, lets call it lifestream: ./manage.py startapp lifestream On the settings.py add the lifestream project to the INSTALLED_APPS and a variable to store your FriendFeed username: FRIENDFEED_USERNAME = 'your_username' In the models.py add a model named Entry: from django.db import models class Entry(models.Model): id = models.CharField(max_length=255, primary_key=True) service_id = models.CharField(max_length=50, null=True, blank=True) service_name = models.CharField(max_length=50, null=True, blank=True) service_icon = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) service_profile = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) title = models.CharField(max_length=255, null=True, blank=True) link = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) updated = models.DateTimeField(null=True, blank=True) published = models.DateTimeField(null=True, blank=True) media_title = models.CharField(max_length=255, null=True, blank=True) media_link = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) media_thumbnail = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.title class Meta: ordering = … -
Internet lifestream with Django
My goal was to archive and display my internet lifestream. My first approach was writing a client for each API of the social networks that I'm in. This turned out to be a complete waste of time and effort. All that I needed after all was a FriendFeed account that would centralize all my feeds. Archiving and displaying your entries with Django is quite simple. First of all, you need to download the Python FriendFeed API client. Then start a new application in your project, lets call it lifestream: ./manage.py startapp lifestream On the settings.py add the lifestream project to the INSTALLED_APPS and a variable to store your FriendFeed username: FRIENDFEED_USERNAME = 'your_username' In the models.py add a model named Entry: from django.db import models class Entry(models.Model): id = models.CharField(max_length=255, primary_key=True) service_id = models.CharField(max_length=50, null=True, blank=True) service_name = models.CharField(max_length=50, null=True, blank=True) service_icon = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) service_profile = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) title = models.CharField(max_length=255, null=True, blank=True) link = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) updated = models.DateTimeField(null=True, blank=True) published = models.DateTimeField(null=True, blank=True) media_title = models.CharField(max_length=255, null=True, blank=True) media_link = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) media_thumbnail = models.URLField(max_length=255, verify_exists=False, null=True, blank=True) created = models.DateTimeField(auto_now_add=True) def __unicode__(self): return self.title class Meta: ordering = … -
It's free; stop whining
Soma FM is arguably the best free online radio service. As of this writing they have 13 channels, most, like their most popular Groove Salad, are electronic/ambient, though Indie Pop Rocks is also immensely popular. Despite being 100% free, people still complain about the service. -
XML-RPC dispatching through Django test client
Django has a cleverly designed test client that creates a WSGIRequest and routes it through your views without the need of a web server. Furthermore it works on a temporary test database, thus any errors won't have any effect on your live database. I'm currently working on an application written using Django. This application, amongst other features, has an XML-RPC interface. The tests for this interface was being done by spawning a local web server and carrying out the tests over the wire. However, it would be nice to exploit the Django test framework. The solution is amazingly simple. I wrote a TestTransport class for xmlrpclib: import cStringIO from xmlrpclib import Transport from django.test.client import Client class TestTransport(Transport): """ Handles connections to XML-RPC server through Django test client.""" def __init__(self, *args, **kwargs): self.client = Client() def request(self, host, handler, request_body, verbose=0): self.verbose = verbose response = self.client.post(handler, request_body, content_type="text/xml") res = cStringIO.StringIO(response.content) res.seek(0) return self.parse_response(res) In my tests where I use the XML-RPC interface I initialize the ServerProxy object with: server = ServerProxy('http://localhost/xmlrpc/', transport=TestTransport()) That's about it. Now calls trough the server object will be handled by the Django test client. In my case I had a decorator around the … -
XML-RPC dispatching through Django test client
Django has a cleverly designed test client that creates a WSGIRequest and routes it through your views without the need of a web server. Furthermore it works on a temporary test database, thus any errors won't have any effect on your live database. I'm currently working on an application written using Django. This application, amongst other features, has an XML-RPC interface. The tests for this interface was being done by spawning a local web server and carrying out the tests over the wire. However, it would be nice to exploit the Django test framework. The solution is amazingly simple. I wrote a TestTransport class for xmlrpclib: import cStringIO from xmlrpclib import Transport from django.test.client import Client class TestTransport(Transport): """ Handles connections to XML-RPC server through Django test client.""" def __init__(self, *args, **kwargs): self.client = Client() def request(self, host, handler, request_body, verbose=0): self.verbose = verbose response = self.client.post(handler, request_body, content_type="text/xml") res = cStringIO.StringIO(response.content) res.seek(0) return self.parse_response(res) In my tests where I use the XML-RPC interface I initialize the ServerProxy object with: server = ServerProxy("http://localhost/xmlrpc/", transport=TestTransport()) That's about it. Now calls trough the server object will be handled by the Django test client. In my case I had a decorator around the … -
Django request logging with rsyslog
In my original post about logging Django requests, I had only tried my code with syslog-ng. It works fine with rsyslog too. -
Presenting truly international dates in Django
If you use a language that's a bit more complex than English (or most western languages, that is), you'll probably have some problems displaying dates that actually don't look like computer-generated. Django-localdates deals with this problem, and tries to tackle the general problem of internationalizing dates. The main issue is, if you want your application to be truly international, you have to find a translator that will translate your templates, messages, emails and everything else that a user might see. However, translating dates isn't that straightforward. The easiest example is US vs British date format. US citizens write the month first, while the British write the month after the date. So, if you have a template that uses now "d F Y", it will look good for a British person, but not for an US person. A Russian would be appaled, because Март isn't the same as марта! django-localdates tries to overcome all this by defining translatable date formats. Every language has a "formal" way to display dates, a short way, a numeric way and so on. So if we could just specify "This date should be formatted to be short" or "This day is the full deal", and have … -
FormWizard: multiple-step forms in Django
Have you ever had to implement a multiple-step form? It can be a headache trying to keep track of all the data, especially while validating each form in the process. Django’s new FormWizard class makes it wickedly easy. -
eSteak - hot MooTools slices
By now there are many javascript frameworks available that make programming easy and encapsulate new and cool functionalities. Surely every framework has its advantages and disadvantages but in my opinion you can't switch between all of them - you have to deceide in favour of one. In my case I have chosen Mootools, as you may have already seen here... A friend of mine and also a co-worker, Grundi, has created a site that answers to the beautiful name of "eSteak" that unites the different scripts for Mootools on a central place, with rating, Mootools dependency listing and so on. The whole thing is user generated content, so its up to all the Mootools developers and even to you to upload scripts and support it! Because the problem with Mootools is that there are really cool scripts out there, but you first have to find them. I hope that eSteak will be filled with a lot of scripts and that it will develop to the central place for Mootools friends and enthusiasts. Update (somewhen in 2013): unfortunately eSteak was taken to the grave in 2010 - check this blog post for more information: http://blog.aplusmedia.de/2010/10/19/esteak-net-end-of-life-announcement/ -
eSteak - hot MooTools slices
By now there are many javascript frameworks available that make programming easy and encapsulate new and cool functionalities. Surely every framework has its advantages and disadvantages but in my opinion you can't switch between all of them - you have to deceide in favour of one. In my case I have chosen Mootools, as you may have already seen here... A friend of mine and also a co-worker, Grundi, has created a site that answers to the beautiful name of "eSteak" that unites the different scripts for Mootools on a central place, with rating, Mootools dependency listing and so on. The whole thing is user generated content, so its up to all the Mootools developers and even to you to upload scripts and support it! Because the problem with Mootools is that there are really cool scripts out there, but you first have to find them. I hope that eSteak will be filled with a lot of scripts and that it will develop to the central place for Mootools friends and enthusiasts. Update (somewhen in 2013): unfortunately eSteak was taken to the grave in 2010 - check this blog post for more information: http://blog.aplusmedia.de/2010/10/19/esteak-net-end-of-life-announcement/ -
eSteak - hot MooTools slices
By now there are many javascript frameworks available that make programming easy and encapsulate new and cool functionalities. Surely every framework has its advantages and disadvantages but in my opinion you can't switch between all of them - you have to deceide in favour of one. In my case I have chosen Mootools, as you may have already seen here... A friend of mine and also a co-worker, Grundi, has created a site that answers to the beautiful name of "eSteak" that unites the different scripts for Mootools on a central place, with rating, Mootools dependency listing and so on. The whole thing is user generated content, so its up to all the Mootools developers and even to you to upload scripts and support it! Because the problem with Mootools is that there are really cool scripts out there, but you first have to find them. I hope that eSteak will be filled with a lot of scripts and that it will develop to the central place for Mootools friends and enthusiasts. Update (somewhen in 2013): unfortunately eSteak was taken to the grave in 2010 - check this blog post for more information: http://blog.aplusmedia.de/2010/10/19/esteak-net-end-of-life-announcement/ -
Adding InnoDB to sqlall output
Have you ever wondered why you can’t have manage.py sqlall output your create table statements as InnoDB tables for mysql? Well I have. I always go in and update the statements by hand to add that after the fact. So I did a bit of pokeing around and figured out a hack to add in [...] -
Yahoo! UI (YUI) + Django templates == Google Code project! FTW!
Let me first preface this blog by saying that I’m not a designer. When it comes to art and creativity, I’m so left brained, I actually wonder if my right brain even partakes in the process. Three things spurred me to release django-yui-layout-templates. I’ve always wanted to see what GoogleCode offered in relation to SourceForge / RubyForge. I’m so caught up in corporate America staring at Java / Ruby code all day, not only haven’t I blogged about anything Django related in quite a while, but it’s nice to get some commentary from the community, i.e. “your code sucks”. (Brings me back to reality) I found myself using the same templates on a variety of projects and figured that I could do my part and help eliminate unncessary cruft/duplication. So without further adieu, check out the project here. I know, I know – nothing revolutionary here, but I figure since Django is picking up some steam, these templates might help a Djangonaut get a head start on their next million dollar idea. Voila! Enjoy! -
ActiveResource for Python
I’ve begun porting Ruby on Rails’ ActiveResource to Python. This is especially useful when dealing with APIs (such as the one I’m currently developing for Slicehost) or other ActiveResource implementations without having to use Ruby (or Rails). -
YUI datatables does not work for IE ?
I have been playing around with the datatables from Yahoo UI package for one of my customers. Much to my surprise though the code does not work for IE. I have been googling around for somebody reporting the same issue but so far I haven't found anything to the effect. I am just following the same example from the YUI site. On using YUI for my work, everything is good but then there are a few issues I am running into :1. caching on the datatable itself does not lend itself to easy doing.2. compatibility issues between browsers doesn't lend itself friendly to enterprise solutions.Going to look more into this. -
PyCon Braindump
PyCon 2008 Brain Dump There are some great roundups of the content at PyCon out there; this isn’t one of them. See, I have this notebook (Moleskine FTW!) I carry with me everywhere, and now it’s chock-full of note from PyCon; this is a braindump. EAV Mammoth replicator Django 1.0 will support Python 2.3, but later releases likely will not. We’ll need to start working on moving to Python 3. -
Help OSI
I try not to get political here, so I’ll try to keep this as neutral as possible. Bruce Perens is running for a board seat at the Open Source Initiative and has asked for public support. My take on this should be pretty obvious from the fact I’ve signed the document. Whether you agree or me or not, though, I’d please ask you to still take a few moments and learn about the debate. -
Django Mercurial mirror tweaks
I really enjoyed my participation in the last Django sprint, but prior commitments prevent me from participating in the PyCon Django sprint that begins today. On the chance that people may be taking advantage of my Mercurial mirror of the Django repository, I made a couple tweaks: Increased the update frequency from hourly to every 15 minutes Added downloadable gzipped tarballs (about 2.5MB for trunk). Have fun! -
WhisperGifts Sees the Light of Day
I got married in March 2007, within a few months of a number of friends. We all shared our trials and tribulations as we each prepared for our big events, and a number of common issues arose. One of these common points of confusion was the preparation of a bridal gift registry - a list of gifts that we would love to receive from our guests. Being somewhat geeky, I started to put together an online bridal registry system that could not only be used by my fiance and I, but also by our friends and family. This case of scratching an itch turned into a service that would eventually become WhisperGifts, the first public offering of Jutda. This service evolved over time into a solution suitable for the commercial prime-time and as of today is ready for public consumption at whispergifts.com. Here's just some of the major benefits of WhisperGifts: Allows your guests to shop at any store they like. Aunty Mary who works for MegaTVCorp can now buy you that 42-inch LCD that you want, without paying department store prices Allows you to describe the types of items you want, rather than selecting a brand and model Lets … -
WhisperGifts Sees the Light of Day
I got married in March 2007, within a few months of a number of friends. We all shared our trials and tribulations as we each prepared for our big events, and a number of common issues arose. One of these common points of confusion was the preparation of a bridal …