Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
twod.wsgi Presentation at the Django User Group in London
Last week I had the pleasure to present twod.wsgi, a library to improve WSGI support in Django, at the Django User Group in London. The slides are now available in OpenDocument and PDF formats.That day I used a demo application which we are going to publish, possibly on Bitbucket. We should be releasing twod.wsgi very soon, as soon as the documentation is finished. So stay tuned! -
jmoiron.net: Johnny Cache
jmoiron.net: Johnny Cache. The blog entry announcing Johnny Cache (“a drop-in caching library/framework for Django that will cache all of your querysets forever in a consistent and safe manner”) to the world. -
Pycon 2010 report II
The first half day report for formal conference activities on February 21.Plenary: IntroductionI helped in registration so I arrived late to listen to Van Lindburgh start the conference. Which was a shame because I like to listen to him speak. Nevertheless, I consoled myself with the knowledge that I had contributed my time and service to help him launch what turned out to be an amazing conference.Keynote: Steve HoldenIn December Steve had presented to the NOVA-Django a much earlier draft of his speech. As much as his stuff back in December was good, what he did at Pycon was right on the money. He was in fine form, and the conclusion was very much Steve Holden at his best.The next night Steve was in rare fine form, but that is a story for another day...Keynote: Guido Van RossumBeing that I am Guido's biggest fan, and have trouble breathing in his presence, you might think I'm a bit biased. Alas, in this case, Guido's talk was not my favorite of the conference. If memory serves, at last year's Pycon he mentioned a desire to remove the "For Life" from BDFL and this year I think that showed a little bit. It … -
Django template2pdf
Django template2pdf -
Johnny Cache
Johnny Cache. Clever twist on ORM-level caching for Django. Johnny Cache (great name) monkey-patches Django’s QuerySet classes and caches the result of every single SELECT query in memcached with an infinite expiry time. The cache key includes a “generation” ID for each dependent database table, and the generation is changed every single time a table is updated. For apps with infrequent writes, this strategy should work really well—but if a popular table is being updated constantly the cache will be all but useless. Impressively, the system is transaction-aware—cache entries created during a transaction are held in local memory and only pushed to memcached should the transaction complete successfully. -
Django Management.tmbundle
Did some work on my [Django Management.tmbundle][1] last night. It now handles running tests when (a) The apps are not directly in the project root, but inside another folder, for instance; and (b) the app/tests.py file has been split into seperate files. The main reason I made this was so that I could run tests and have clickable links in the results window for the location of failing tests. There is still much to do on this. I am considering re-writing it in python rather than ruby, so I can programmatically find the app name, rather than guess it. I also want to refactor the hell out of it and make it much nicer. Anyway, if you are interested, you can find the most recent version at [http://github.com/schinckel/Django-Management.tmbundle][1] - and I think it also appears in TextMate's getBundles bundle. [1]: http://github.com/schinckel/Django-Management.tmbundle -
Dynamic form generation
I had the pleasure of being on a forms panel at PyCon 2010 chaired by Brandon Craig Rhodes. To get a stable baseline, Brandon asked each of us to provide code showing how each forms toolkit might tackle a problem: Imagine that someone has already written a form with your forms library. The form looks something like this: New username: __________ Password: __________ Repeat password: __________ [Submit] Now, someone from Marketing comes along and announces that the developers must add some additional questions to the form - and the number of extra questions is not determined until runtime! -
The darker side of Pinax
I really like the concept of Pinax, but I’m beginning to see the darker sides of the project. Here’s the fundamental issue: Pinax does a completely kick ass job of making a combined and base project that pulls together a … Continue reading → -
Django Advent: Scaling Django
Django Advent: Scaling Django. Mike Malone’s advice on scaling Django applications, including taking advantage of new features in 1.2. -
Open vs Closed Source
I have heard open source compared a lot to socialism, or maybe better as something that is not capitalism. Equally frustrating, I have been around the crowd that jeers the people that sell closed source software. There is a lot of misperceptions that exist about both commercial software and open source. I have been involved with both and have worked around people who have held views on opposite ends of the spectrum. There is room for both closed source, proprietary software as well as open source software. Bill Gates is Evil. Linux is for Communists. Software should be free. Patents stifle innovation. If you have worked in technology around other people at all, you have heard these types of statements before. Are we really supposed to believe these types of statements? Furthermore, what good does it accomplish? My Background I started my career in closed source and couldn't believe how or why people would "work for free" or give their code away. Didn't they know that not many people can write software -- it was valuable, they shouldn't just give it away. Later, I learned Python and then Django. I started using some open source libraries to build solutions in … -
Open vs Closed Source
I have heard open source compared a lot to socialism, or maybe better as something that is not capitalism. Equally frustrating, I have been around the crowd that jeers the people that sell closed source software. There is a lot of misperceptions that exist about both commercial software and open source. I have been involved with both and have worked around people who have held views on opposite ends of the spectrum. There is room for both closed source, proprietary software as well as open source software. Bill Gates is Evil. Linux is for Communists. Software should be free. Patents stifle innovation. If you have worked in technology around other people at all, you have heard these types of statements before. Are we really supposed to believe these types of statements? Furthermore, what good does it accomplish? My Background I started my career in closed source and couldn't believe how or why people would "work for free" or give their code away. Didn't they know that not many people can write software -- it was valuable, they shouldn't just give it away. Later, I learned Python and then Django. I started using some open source libraries to build solutions in … -
New Python Library: Bleach
We’ve released another Python library: Bleach, for sanitizing HTML and automatically linking URLs in text, that we’re using on addons.mozilla.org and support.mozilla.com. It’s based on html5lib, which we chose because of its foundation in web standards and its active development community. Bleach is available on Github and PyPI. Bleach uses a tree-walking approach to automatically [...] -
New Python Library: Bleach
We’ve released another Python library: Bleach, for sanitizing HTML and automatically linking URLs in text, that we’re using on addons.mozilla.org and support.mozilla.com. It’s based on html5lib, which we chose because of its foundation in web standards and its active development community. Bleach is available on Github and PyPI. Bleach uses a tree-walking approach to automatically [...] -
How to Store Arbitrary Data in a Django Model
I have a number of different places where I have wanted to store arbitrary data along with structured data in a Django model. This is data that I wouldn't necessarily care to use a value to retrieve data but when displaying or working with a record or records of this data, being able to have this data available in a manner that I didn't have to parse was nice. My solution was to serialize/deserialize in and out of JSON using simplejson and a Field class that derives from a TextField. i think it is easier to just read the code and the example of how to use it in the gist below than for me to continue with my rambles. The Code UPDATE: It wasn't clear in this post. This wasn't my code, as I had previously pointed out. Just wanted to be clear that I have found this solution useful and have used the snippet so much that I feel like it's mine -- but it's not. :) -
How to Store Arbitrary Data in a Django Model
I have a number of different places where I have wanted to store arbitrary data along with structured data in a Django model. This is data that I wouldn't necessarily care to use a value to retrieve data but when displaying or working with a record or records of this data, being able to have this data available in a manner that I didn't have to parse was nice. My solution was to serialize/deserialize in and out of JSON using simplejson and a Field class that derives from a TextField. i think it is easier to just read the code and the example of how to use it in the gist below than for me to continue with my rambles. The Code from django.db import models from django.utils import simplejson as json from django.conf import settings from datetime import datetime class JSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, datetime): return obj.strftime('%Y-%m-%d %H:%M:%S') elif isinstance(obj, datetime.date): return obj.strftime('%Y-%m-%d') elif isinstance(obj, datetime.time): return obj.strftime('%H:%M:%S') return json.JSONEncoder.default(self, obj) class JSONField(models.TextField): def _dumps(self, data): return JSONEncoder().encode(data) def _loads(self, str): return json.loads(str, encoding=settings.DEFAULT_CHARSET) def db_type(self): return 'text' def pre_save(self, model_instance, add): value = getattr(model_instance, self.attname, None) return self._dumps(value) def contribute_to_class(self, cls, name): self.class_name = cls super(JSONField, … -
PyCon 2010 Recap
The videos from PyCon 2010 appear to be coming online now and I highly recommend checking them out if you weren't able to attend or missed some of the sessions you wanted to see while there at other sessions. There was a ton of great stuff to soak in through osmosis. In addition, it was great to meet others in the community that I know through IRC / Twitter / Email / Projects. Here is my recap of things that impressed me and that I saw as directly applicable to what I am working on. redis / pyres / celery redis, pyres, celery I need to use Redis with pyres or celery. Could replace a lot of my crontabs Could replace local queuing (versus distributed queuing running in the cloud). Could replace adhoc email queue infrastructure Simplifies stuff done asynchronously with crontabs - queue up the fact that something needs to be done at the moment instead of running queries repeatedly looking for conditions to trigger action. Becomes super simple to mark things as something to execute asynchronously so more functionality can be added without slowing down website (e.g. logging, near real-time data warehousing, etc.) picloud picloud Looks promising, however, … -
PyCon 2010 Recap
The videos from PyCon 2010 appear to be coming online now and I highly recommend checking them out if you weren't able to attend or missed some of the sessions you wanted to see while there at other sessions. There was a ton of great stuff to soak in through osmosis. In addition, it was great to meet others in the community that I know through IRC / Twitter / Email / Projects. Here is my recap of things that impressed me and that I saw as directly applicable to what I am working on. redis / pyres / celery redis, pyres, celery I need to use Redis with pyres or celery. Could replace a lot of my crontabs Could replace local queuing (versus distributed queuing running in the cloud). Could replace adhoc email queue infrastructure Simplifies stuff done asynchronously with crontabs - queue up the fact that something needs to be done at the moment instead of running queries repeatedly looking for conditions to trigger action. Becomes super simple to mark things as something to execute asynchronously so more functionality can be added without slowing down website (e.g. logging, near real-time data warehousing, etc.) picloud picloud Looks promising, however, … -
Pycon 2010 report I
Pycon was an incredible learning experience and networking opportunity. I met many good friends again and made just as many new ones. In addition, this was the first time I presented and did so on Pinax two times. Furthermore, in the name of diversity, this instance of Pycon saw the premiere of the Financial Assistance Grant for Women. We also had a dedicated talk on Diversity as a Dependency. The benefit this focus on diversity was that...um...yeah...like...uh...um...Diversity RocksDid I learn a lot at pycon? Heck yeah. Networking was life changing. And unlike previous conferences, I'm in a position to take advantages of opportunities offered. The next few weeks and months will see a lot of changes and challenges for me. Note: I've got to keep some things under wraps for now so I'm going to have to aggressively moderate comments. Feel free to comment, just don't take comment rejections personally. -
Background task processing and deferred execution in Django
Or, Celery + RabbitMQ = Django awesomeness! As you know, Django is synchronous, or blocking. This means each request will not be returned until all processing (e.g., of a view) is complete. It's the expected behavior and usually required in web applications, but there are times when you need tasks to run in the background (immediately, deferred, or periodically) without blocking. Some common use cases: Give the impression of a really snappy web application by finishing a request as soon as possible, even though a task is running in the background, then update the page incrementally using AJAX. Executing tasks asynchronously and using retries to make sure they are completed successfully. Scheduling periodic tasks. Parallel execution (to some degree). There have been multiple requests to add asynchronous support to Django, namely via the python threading module, and even the multiprocessing module released in Python2.6, but I doubt it will happen any time soon, actually I doubt it will ever happen. This is a common problem for many, and after scouring over many forum posts the following proposed solution keeps popping up, which reminds of me of the saying "when all you have is a hammer, everything looks like a nail". … -
Background task processing and deferred execution in Django
Or, Celery + RabbitMQ = Django awesomeness! As you know, Django is synchronous, or blocking. This means each request will not be returned until all processing (e.g., of a view) is complete. It's the expected behavior and usually required in web applications, but there are times when you need tasks to run in the background (immediately, deferred, or periodically) without blocking. Some common use cases: Give the impression of a really snappy web application by finishing a request as soon as possible, even though a task is running in the background, then update the page incrementally using AJAX. Executing tasks asynchronously and using retries to make sure they are completed successfully. Scheduling periodic tasks. Parallel execution (to some degree). There have been multiple requests to add asynchronous support to Django, namely via the python threading module, and even the multiprocessing module released in Python2.6, but I doubt it will happen any time soon, actually I doubt it will ever happen. This is a common problem for many, and after scouring over many forum posts the following proposed solution keeps popping up, which reminds of me of the saying "when all you have is a hammer, everything looks like a nail". … -
Background task processing and deferred execution in Django
Or, Celery + RabbitMQ = Django awesomeness! As you know, Django is synchronous, or blocking. This means each request will not be returned until all processing (e.g., of a view) is complete. It's the expected behavior and usually required in web applications, but there are times when you need tasks to run in the background (immediately, deferred, or periodically) without blocking. Some common use cases: Give the impression of a really snappy web application by finishing a request as soon as possible, even though a task is running in the background, then update the page incrementally using AJAX. Executing tasks asynchronously and using retries to make sure they are completed successfully. Scheduling periodic tasks. Parallel execution (to some degree). There have been multiple requests to add asynchronous support to Django, namely via the python threading module, and even the multiprocessing module released in Python2.6, but I doubt it will happen any time soon, actually I doubt it will ever happen. This is a common problem for many, and after scouring over many forum posts the following proposed solution keeps popping up, which reminds of me of the saying "when all you have is a hammer, everything looks like a nail". … -
Now Serving: Everyone!
This has been a very exciting week for us, as we're now officially launched! We've taken away all the beta aspects of the site and now anyone can signup for the site! This also means that the world can see your recipes, so feel free to share with anyone/everyone! We've added a new sharing feature that lets you enter someone's e-mail address to pass a recipe along. You can also share the recipes via Twitter, Facebook and a new short URL (like http://frkn.it/r/1137/). You may have noticed a couple other changes around here in the last week. The site got an overall look/feel upgrade and a shiny new logo. We're still polishing but pretty pleased thus far. And the logo looks great on t-shirts... As usual, we've also fixed a couple bugs: The fork history now works regardless of which browser you're using. Fixed recipes being duplicated in the "All Recipes" area. Fixed the message when you get followed by someone else. Added About, Pricing & Contact pages. However, we're not about to rest on our laurels. We've got plenty to do and will be rolling out new things as we finish them. If you were a beta user, we'll … -
4 things to know for NoSQL Django coders
Update 2: Take a look at the django-dbindexer. Since its release it's possible to use __month= queries so you don't have to use tricky code which uses a date range query for example. Additionally django-dbindexer adds support for simple JOINs. Update: MongoDB backend is now available too :) This is the first post in a series that should give you an impression of what non-relational / NoSQL model code looks like with django-nonrel. As mentioned in the previous post, you can see django-nonrel in action on our new website (we use it ourselves in the spirit of dogfooding). While everything discussed here should work on all nonrel DBs we currently only have an App Engine backend and soon a MongoDB backend (more on that once it's finished). If you want to help with other backends (Redis, SimpleDB, CouchDB, etc.) please join the discussion group. We'll dive into the source of our website which contains a very simple "CMS" and a blog app which can host multiple independent blogs. It runs the admin interface unmodified, but with some limitations. Overall, the code is surprisingly similar to normal Django code, but you'll also find that nonrel-compatible models need their own way of … -
Web Site Performance Optimizations
Recently I have done some optimizations to make telvee a little faster using django_compressor and making sprites for background images. Good news is substantial changes to development environment and the design wasn’t required. I’ll get into details below. But first I’d like to write about the theory a little bit. I follow (and read with [...] -
Django patterns, part 4: forwards generic relations
My last post talked about how to follow reverse generic relations efficiently. However, there's a further potential inefficiency in using generic relations, and that's the forward relationship. If once again we take the example of an Asset model with a GenericForeignKey used to point at Articles and Galleries, we can get from each individual Asset to its related item by doing asset.content_object. However, if we have a whole queryset of Assets, doing this: {% for asset in assets %} {{ asset.content_object }} {% endfor %} will result in as many queries as there are assets - in fact it's n+m, where n is the number of assets and m is the number of different content types, as you'll have one extra query per type to get the ContentType object. (Although it might be slightly less than that if you've used ContentTypes elsewhere, as the model manager caches lookups on the assumption that they never change once they've been set.) However, luckily we can make this much more efficient as well, again using a variation of the dictionary technique. generics = {} for item in queryset: generics.setdefault(item.content_type_id, set()).add(item.object_id) content_types = ContentType.objects.in_bulk(generics.keys()) relations = {} for ct, fk_list in generics.items(): ct_model = …