Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Redis PubSub wrapper for Python
Recently I've found that there's no reasonable simple and useful Redis pub sub examples around. So, here is my dead simple wrapper how to implement it without any unnecessary overhead. -
Taking up the gauntlet: defense of Django
I'm taking up the gauntlet. A gauntlet that has been thrown down with considerable force and eloquence by my colleague Gijs on his new weblog in a post called Django is just an API. The title comes from a similar article about Rails being just an API. Transitioning to modern times We have a big stack of Django apps (called Lizard, 50+ apps) and some 40 sites. I have a quite good description of how it all fits together in a previous post where I told about a pyramid experiment. Summary: we use all of Django (models, templates, views, staticfiles, etc). Reusable apps. Two big core apps that everything inherits from for basic user interface and basic map handling. To quote Gijs: ... we are currently transitioning to API-based de-coupling of back-end and front-end. In other words: a client-side user interface which talks to an API for data. This web app should just be one of the api-consuming clients, not privileged in any way compared to an iPhone or Android native client. So: Django is relegated to the dustbin of history and is mercifully allowed to serve up an API (probably until it is replaced in due course with some … -
Churning behind the scenes
At the moment there are several Evennia projects churning along behind the scenes, none of which I've yet gotten to the point of pushing into a finished state. Apart from bug fixes and other minor things happening, these are the main updates in the pipeline at the moment.Multiple Characters per Player/SessionEvennia has for a long time enforced a clean separation between the Player and the Character. It's a much appreciated feature among our users. The Player is "you", the human playing the game. It knows your password, eventual user profile etc. The Character is your avatar in-game. This setup makes it easy for a Player to have many characters, and to "puppet" characters - all you need to do is "disconnect" the Player object from the Character object, then connect to another Character object (assuming you are allowed to puppet that object, obviously). So far so good. What Evennia currently doesn't support is being logged in with different client sessions to the same Player/account while puppeting multiple characters at the same time. Currently multiple client sessions may log into the same Player account, but they will then all just act as separate views of the same action (all will see the same output, you can … -
Virtualenvwrapper for your production server
Virtualenvwrapper is a popular tool for the Django developer who works on several different projects at the same time. I have not seen much on the web about how this tool can also simplify your production setup, in particular Fabric and crontab. So here's a quick writeup... -
Taking up the gauntlet: defense of Django
I'm taking up the gauntlet. A gauntlet that has been thrown down with considerable force and eloquence by my colleague Gijs on his new weblog in a post called Django is just an API. The title comes from a similar article about Rails being just an API. Transitioning to modern times We have a big stack of Django apps (called Lizard, 50+ apps) and some 40 sites. I have a quite good description of how it all fits together in a previous post where I told about a pyramid experiment. Summary: we use all of Django (models, templates, views, staticfiles, etc). Reusable apps. Two big core apps that everything inherits from for basic user interface and basic map handling. To quote Gijs: ... we are currently transitioning to API-based de-coupling of back-end and front-end. In other words: a client-side user interface which talks to an API for data. This web app should just be one of the api-consuming clients, not privileged in any way compared to an iPhone or Android native client. So: Django is relegated to the dustbin of history and is mercifully allowed to serve up an API (probably until it is replaced in due course with some … -
Virtualenvwrapper for your production server
Virtualenvwrapper is a popular tool for the Django developer who works on several different projects at the same time. I have not seen much on the web about how this tool can also simplify your production setup, in particular Fabric and crontab. So here's a quick writeup... -
Version Control and the Django Tutorial
Subversion Under ControlSimilar to last semester teams are required to use version control, Subversion (SVN) in particular, to manage their project's source code. Last semester's project was my first experience with SVN, which was quite a learning process.Shortly into the creation of the repository the need for standard protocols was realized. In particular the team needed to write succinct commit messages which convey why the commit was made. The message must include what problem was fixed, or if a new feature was added a use case for said feature. Messages which could be found on whatthecommit.com or other similar sites should be avoided at all costs. Eventually the contributing members of the group adopted a standard messaging format which helped greatly with project development. In spite of various issues, gaining firsthand knowledge at how SVN handles conflicts and merges was very educational. After a few frustrating experiences I promptly learned to check for and pull down new versions before starting work on a new task.Despite my previous experiences with SVN I decided to follow along with the exercises in Chapter 4 of The Teaching Open Source (TOS) textbook (link on the sidebar). Unfortunately, I was unable to checkout the tutorial repo as it … -
Hurray for tests: preparing a buildout pull request
Last week, I prepared a pull request for zc.buildout 2.0 to include buildout-versions' functionality in buildout itself. I had looked at the inner workings of buildout before and even prepared a pull request before, but that was a small one. buildout-versions monkeypatches internals of buildout so that it can print a list of picked versions at the end of your buildout run. Quite essential if you want to make your buildouts repeatable. You don't want too many surprises by new versions. So: I integrated a buildout extension that did some buildout-monkeypatching into buildout itself. More specifically into a historically quite involved piece of buildout. Picking the right versions is at the core of buildout, so making a mistake there is a big no-no :-) Where did I get the confidence for making such a pull request? From the tests. There are a lot of tests in buildout's code. They're mostly doctests. Doctests have their drawbacks (and advantages). But they're tests anyhow. And I could find a couple of good spots to add my documentation and tests to test the functionality I was copying over from buildout-versions. And I could be certain that if I broke something, the existing tests would … -
Testing and Django settings
Django uses a from django.conf import settings configuration mechanism, which makes it hard to test. The settings object is global. You have to do set a setting and revert the change at the end of a test; quite messy. You can do a bit better, in such a situation, by using the excellent mock library. But even mock is defeated sometimes by Django's settings. I tried a couple of variants like the following and failed to change the settings: import mock class XYZTest(TestCase) @mock.patch('django.conf.settings.DEBUG', False) def test_xyz(self): # ... # Well, I'm importing settings in my views module... @mock.patch('my_app.views.settings.DEBUG', False) def test_xyz2(self): # ... After some googling I discovered something I totally missed. Django 1.4 has something real useful. The @override_settings decorator. Does exactly what I want it to do: from django.test.utils import override_settings ... class XYZTest(TestCase) @override_settings(DEBUG=False) def test_xyz(self): # ... Hurray! -
Django Extensions 1.0.3
A new version of Django-Extensions just hit PyPi :) We call it: 1.0.3 ChangeLog: FEATURE: notes command now shows BUG tags FEATURE: support SSL in runserver_plus DOCS: Better documentation for runserver plus DOCS: Better documentation for runscript command FIX: truncation on admin widgets FIX: allow AutoSlugField to work with inherited models. FIX: show_templatetags command FIX: RSA public key check for keyzcar encrypted fields FIX: graph_models command for Django 1.5 -
Content types and Django CMS
The new ENB website One of our latest projects to go live is a new website for the English National Ballet. Part of a major rebrand, we completely replaced their old PHP site with a new content-managed site powered by Django CMS. Django CMS is very flexible, largely due to its minimalistic approach. It provides no page templates out of the box, so you can construct your HTML from the ground up. This is great if you want to make a CMS with a really strong design, because there is very little interference from the framework. However, its minimalistic approach also means that you sometimes have to write extra code to tie all the content together. A good example of this is content types. In Django CMS, there is only one content type: Page. It has certain fields associated with it e.g. title, slug, published. Any other information that appears on a page comes courtesy of plugins. The default Django CMS plugins give you everything you need to add arbitrary text, images and video to a page. But what if you want more fields for your page? Let’s say, for example, you are representing a ballet production and you want … -
Djangorecipe updated for the upcoming buildout 2.0
zc.buildout 2.0 is almost finished (the 2.0 beta 1 came out last week). It is mostly a simplified 1.4.4 zc.buildout that is better maintainable. Simplifications include only supporting distribute instead of also setuptools. And not supporting multiple python versions within one buildout: the one you run buildout with is the one that gets used. And it loses the 1.5/1.6/1.7 complexity of selective isolation from system packages. It also gains some stuff like better defaults. And my patch :-), so it supports distutils-style scripts, too. Handy for installing pyflakes and docutils. And, as I discovered a week ago, you can also let it install all scripts of all required packages with the dependent-scripts = true setting. Anyhow, time to update djangorecipe, as there was a small change in the way buildout 2.0 calls a recipe. Not many recipes will be bitten by it: you don't get passed the python executable anymore. This is only useful when you want to use a different python from the one you run your buildout with. So... I could simplify the code, too, by throwing out support for different python versions :-) Good python 3 news! The upcoming django 1.5 (at release candidate status now) works … -
Translating sentences with substitutions
The problem Many programs build up sentences using bits - often a template into which different things might be substituted. However, the things you substitute into a sentence can change the sentence, and vice-versa, in ways that are not anticipated by the programmer. For example, plurals. In English, you might try code like this: if n == 1: return "I have 1 pig" else: return "I have %s pigs" % n Localising these strings gives problems, because the rules for how to create plural forms is different in every language. This specific problem is generally considered 'solved' by the use of gettext, but many more exist. For example, we have another problem as soon as we start substituting nouns: "Delete selected %s?" % object_name Various attributes about the noun could affect the sentence. In French, the adjective "selected" needs to agree in gender with the noun being substituted in. So you cannot lookup the translations for "Delete selected %s" and for object_name separately. (This is a real example picked from Django source code). Further, depending on how the sentence uses the noun, the form of the noun might need to change. For example, the noun might appear in the accusative … -
Beginner's Guide to PyCon 2013 Part II
This is Part II in a series of blog posts about PyCon US 2013. The goal is to provide a handy reference guide for first time attendees of the world's largest Python conference. Part I was mostly about tutorials, this post will be about registration and the first day of talks. Registration If you haven't done so yet, please register now. Last year PyCon sold out way in advance, and hundreds missed the event. Which is a shame, because the conference is awesome! Keep in mind that the money you spend on registration will go towards a very good thing. You see, after the costs for running PyCon are subtracted, the rest will go to the non-profit Python Software Foundation (PSF). In addition to supporting the Python language itself, the PSF provides financial aid and grants for aspiring developers around the world. Which means the money you spend registering for PyCon will literally change people's lives. This isn't an idle exaggeration, this outreach has made a difference for you, me, and arguably the world. I would love to say more, but that's an article for another day... Alright, on to the talks! Talk Attendance Guidelines At PyCon, talks are either … -
Beginner's Guide to PyCon 2013 Part II
This is Part II in a series of blog posts about PyCon US 2013. The goal is to provide a handy reference guide for first time attendees of the world's largest Python conference. Part I was mostly about tutorials, this post will be about registration and the first day of talks. Registration If you haven't done so yet, please register now. Last year PyCon sold out way in advance, and hundreds missed the event. Which is a shame, because the conference is awesome! Keep in mind that the money you spend on registration will go towards a very good thing. You see, after the costs for running PyCon are subtracted, the rest will go to the non-profit Python Software Foundation (PSF). In addition to supporting the Python language itself, the PSF provides financial aid and grants for aspiring developers around the world. Which means the money you spend registering for PyCon will literally change people's lives. This isn't an idle exaggeration, this outreach has made a difference for you, me, and arguably the world. I would love to say more, but that's an article for another day... Alright, on to the talks! Talk Attendance Guidelines At PyCon, talks are either … -
Crafting your Conference Talk Proposal
With the voting period over for DjangoCon Europe talk proposals I wanted to take a couple of minutes and go over what I think makes a good conference talk proposal and a couple of things that you shouldn’t do. Keep it Informative A lot of people try to be funny in their proposals but miss out on the key points. Your proposal should include a brief description of what you’ll be talking about, the audience that it’s intended for and anything else that you think would be useful for the audience. Keep it Short Conferences get a lot of talk proposals. PyCon US got 450 submissions for 114 slots. DjangoCon Europe got 74 submissions for 20 slots. With such competition the reviewers have to go over a lot of content. It’s important to keep your proposal short and sweet so you don’t bore the reviewers and risk them skipping over your talk. I haven’t done any statistical analysis but a brief look over the proposals for DjangoCon EU makes it look like the sweet spot for proposal length is 4-7 sentences. Shorter and the reviewers can’t get enough relevant information, longer they get bored and go on to the next … -
Pjax vs JSON
At DjangoCon US 2012 I asked a question about performance after the BDFL keynote on Pjax. Asking about performance is never a good idea since it is never the most important thing. I was attempting to evaluate Pjax versus the plethora of Javascript based rendering that was being discussed. A common idea was to use the same template language in Django as you use in Javascript. The Meteor keynote explained that just sharing a template language doesn't solve the hard problems of passing the data and the logic about pre-rendering the data to the client. The Django template language is very simple, but it still lets you indirectly run arbitrarily complex code. All of that logic either has to be reimplemented on the client or the results magically exposed there. Pjax keeps rendering of templates on the server side and uses push state and ajax to optimize the user experience by avoiding page refreshes. Blocks of HTML are send from the server and installed on the existing page. I was looking for a comparison of the performance of Pjax vs Javascript rendering, which in the end isn't a simple question to answer. Even so I think it is worth having … -
Pjax vs JSON
At DjangoCon US 2012 I asked a question about performance after the BDFL keynote on Pjax. Asking about performance is never a good idea since it is never the most important thing. I was attempting to evaluate Pjax versus the plethora of Javascript based rendering that was being discussed. A common idea was to use the same template language in Django as you use in Javascript. The Meteor keynote explained that just sharing a template language doesn't solve the hard problems of passing the data and the logic about pre-rendering the data to the client. The Django template language is very simple, but it still lets you indirectly run arbitrarily complex code. All of that logic either has to be reimplemented on the client or the results magically exposed there. Pjax keeps rendering of templates on the server side and uses push state and ajax to optimize the user experience by avoiding page refreshes. Blocks of HTML are send from the server and installed on the existing page. I was looking for a comparison of the performance of Pjax vs Javascript rendering, which in the end isn't a simple question to answer. Even so I think it is worth having … -
Getting to know the Django Community
Joining the ProjectIn order to ascertain a better sense of the community surrounding Django, I followed the advice listed on the project's Contributing to Django page. Initially I began by joining their Internet Relay Chat (IRC) channels on freenode.net. Not wanting the hassle of determining which IRC client to use, I opted for the webchat service on freenode. Although it has been well over a decade since my last ventures into IRC, it appeared not much had changed on the surface, but I am positive as I continue to use IRC I will begin to find the changes.The django project currently operates two IRC channels, #django for django users, and #django-dev for django development. Unsurprisingly, there was stark difference between the two rooms. #django was lively with several users asking questions of various complexities. While not all of the questions were answered (at least in the main chat), the answers provided were in a polite and helpful fashion. In contrast #django-dev was completely silent. Additionally while I can peruse the #django logs at http://django-irc-logs.com/ I am currently unable to find a similar logging site for the developers channel.FunkyBob once again solving a user's issue.The next step in the process of acclimating … -
Beginner's Guide to PyCon 2013 Part I
New to Python and thinking about going to the upcoming PyCon US for the first time? You know, that big Python conference taking place near San Francisco in March? Or perhaps you signed up already and are getting worried about being overwhelmed by hundreds of tutorials, talks, and activities? No worries! This multi-part guide will aid you in getting the most out of attending one of the best technical conferences on the planet. I'm going to share how to get through the whole event in good shape and cover some incredible beginner friendly events. The Basics First off, register already! PyCon US sold out last year around this time. Don't be left out in the cold. Buy your ticket now before it's too late! Now that you've got that done, keep in mind that Python has two days of tutorials, three days of talks, and four days of sprints. Nine days of Python! The trick is to not get exhausted or sick. Therefore, do the following every day of the conference: Take at least one shower. Please. Eat at least two good meals. Make a point of sitting with different people at each meal and introducing yourself. Make new friends! … -
Beginner's Guide to PyCon 2013 Part I
New to Python and thinking about going to the upcoming PyCon US for the first time? You know, that big Python conference taking place near San Francisco in March? Or perhaps you signed up already and are getting worried about being overwhelmed by hundreds of tutorials, talks, and activities? No worries! This multi-part guide will aid you in getting the most out of attending one of the best technical conferences on the planet. I'm going to share how to get through the whole event in good shape and cover some incredible beginner friendly events. The Basics First off, register already! PyCon US sold out last year around this time. Don't be left out in the cold. Buy your ticket now before it's too late! Now that you've got that done, keep in mind that Python has two days of tutorials, three days of talks, and four days of sprints. Nine days of Python! The trick is to not get exhausted or sick. Therefore, do the following every day of the conference: Take at least one shower. Please. Eat at least two good meals. Make a point of sitting with different people at each meal and introducing yourself. Make new friends! … -
The Making Of The "Getting Started With Django" Music
The Making Of The "Getting Started With Django" Music -
Two Scoops of Django FAQ
The launch of the Two Scoops of Django: Best Practices for Django 1.5 book has gone pretty well. The response has been almost entirely positive and sales have been pretty brisk. We've gotten a ton of great, constructive editorial feedback, which we're sorting through as we race towards the BETA release. Here are answers to the commonly asked questions: When can I buy the book via PayPal? We will support PayPal in either the BETA or FINAL release of the book. In order to handle PayPal we need to find a reputable e-publisher that supports it that gives us similar rates, customer service, and product control (updates at any time, uploads of PDF, no surprise charges, etc) as Gumroad. If you know of an e-publisher who is willing to provide that same level of service, please let me know. For the record, we aren't leaving Gumroad. We just want to support developers and students who don't have credit cards. note: While we could certainly write our own publishing platform, that would delay work on the book. ;-) When can I get a Kindle (mobi) or ePub version? Our plan is to support those formats in either the BETA or FINAL … -
Two Scoops of Django FAQ
The launch of the Two Scoops of Django: Best Practices for Django 1.5 book has gone pretty well. The response has been almost entirely positive and sales have been pretty brisk. We've gotten a ton of great, constructive editorial feedback, which we're sorting through as we race towards the BETA release. Here are answers to the commonly asked questions: When can I buy the book via PayPal? We will support PayPal in either the BETA or FINAL release of the book. In order to handle PayPal we need to find a reputable e-publisher that supports it that gives us similar rates, customer service, and product control (updates at any time, uploads of PDF, no surprise charges, etc) as Gumroad. If you know of an e-publisher who is willing to provide that same level of service, please let me know. For the record, we aren't leaving Gumroad. We just want to support developers and students who don't have credit cards. note: While we could certainly write our own publishing platform, that would delay work on the book. ;-) When can I get a Kindle (mobi) or ePub version? Our plan is to support those formats in either the BETA or FINAL … -
From the Bazaar: Django and Sugar Labs
FOSS Experiences and Reflections* Update: Add section on my experiences with Sugar OS.Eric Raymond's essay The Cathedral and the Bazaar is an intriguing look at the differences between the closed and open approaches in software development. Raymond defines the closed approach as being akin to building a cathedral, small teams or individual geniuses meticulously designing and crafting the software, but never sharing until the project is completed. The author contrasts this with the open source approach epitomized by the development of the Linux OS kernel. This style, labeled the bazaar style, is marked by its mix of different agendas & development approaches, soliciting and using contributions from people outside of the main development team, and releasing software and updates early and often. While the author clearly prefers the bazaar style of development, I still believe both approaches have a place in software development. One can point to many successful implementations of the bazaar approach like GIMP or Perl, and surely no one can deny the accomplishments of software cathedrals such as Apple's iOS or Mac OS X.After the brief introduction of the cathedral and bazaar concepts, Raymond proceeds to detail his stewardship over the open source program, fetchmail, and the development of Linux OS as …