Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
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 = … -
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 = … -
Forget The Pony
This is too good not to share (and thank you Eric for tweeting the link): Forget that pink pony as the mascot of Django, one of our very own, Eric Florenzano, appears to already have magical powers. I wish we could have seen the light saber during one of his PyCon talks. :) -
Forget The Pony
This is too good not to share (and thank you Eric for tweeting the link): Forget that pink pony as the mascot of Django, one of our very own, Eric Florenzano, appears to already have magical powers. I wish we could have seen the light saber during one of his PyCon talks. :) -
Forget The Pony
This is too good not to share (and thank you Eric for tweeting the link): Forget that pink pony as the mascot of Django, one of our very own, Eric Florenzano, appears to already have magical powers. I wish we could have seen the light saber during one of his PyCon talks. :) -
jQuery 1.4.2 Released
Just a quick note alerting everyone to the fact that jQuery has gotten EVEN EASIER AND FASTER. Go check out the release notes. Related posts:jQuery 1.4 Released jQuery 1.3.1 Go For Launch jQuery 1.4 Alpha 1 Released Related posts:jQuery 1.4 Released jQuery 1.3.1 Go For Launch jQuery 1.4 Alpha 1 Released -
В одну корзину
Один из самых часто задаваемых вопросов на форумах по Джанге -- как на одной странице выводить информацию из разных информационных блоков (пример такой ветки или вот совсем свежий). Давайте попробуем разобраться в стандартных способах решения данной задачи. Я специально не хочу рассматривать тут какие-то сторонние решения просто из-за того, что их много и они не интересны с точки зрения изучения классических методик применения возможностей Джанги. Основной проблемой с которой сталкиваются вопрошающие -- как получить все нужны данные в одной вьюхе и зачастую из разных приложений. Это усугубляется тем, что у большинства в подсознании сидит необходимость разделения приложений на максимально независимые компоненты. И это правильное желание. Другое дело, что не надо этим принципом злоупотреблять. Если всё-таки ваши приложения нуждаются друг в друге достаточно сильно, то нет ничего плохого в том чтобы иметь в них перекрестные импорты и заимствовать функционал (в том числе по получению данных) так или иначе. Другое дело что таком случае стоит подумать о том, что возможно они настолько жестко связаны, что должны быть единым целым, т.е. одним приложением по сути. Но и даже в этом случае имеет смысл как-то чуть-чуть отделить общие данные от локальных. Обычно исходной целью стремления получить данные из разных приложений являются всякие виджеты, информеры … -
jacobian's django-deployment-workshop
jacobian’s django-deployment-workshop. Notes and resources from Jacob’s 3 hour Django deployment workshop at PyCon, including example configuration files for Apache2 + mod_wsgi, nginx, PostgreSQL and pgpool. -
DjangoSki checklist
Sadly Matt Berg won't be able to make it DjangoSki. Far too busy at the moment in Uganda working on the next version of Child Count. That's a shame, we'll get him next year when he's had time to catch up on his skiing a bit ;). Very fortunate to have Brian Leroux, a self described "software hack" from Nitobi coming to speak in Matt's place. Brian works on mobile apps and things like PhoneGap, XUI and Lawnchair. Checklist for DjangoSki: Laptop Passport (for any non-Canadians that is) Skis / snowboards and gear Hot tub gear We have a few sprint topics planned on the wiki, but if you've got your own, please come ready with those ideas.