Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
An alternative RapidSMS router implementation (with Celery!)
We've been using RapidSMS, a Django-powered SMS framework, more and more frequently here at Caktus. It's evolved a lot over the past year-- from being reworked to feel more like a Django app, to merging the rapidsms-core-dev and rapidsms-contrib-apps-dev repositories into a single codebase (no more submodules!), to finally becoming installable via pypi. The "new core" ... -
Caktus Lightning Talk Lunches
Last month we hosted the first talk in our new Caktus Lightning Talk Lunch series. We started this series to get together and learn about new projects, different applications, and interesting topics that the Caktus team has been working on. Lunch was provided from Buns in Chapel Hill and Mark Lavin gave the first talk. Mark presented ... -
Extending different base template for ajax requests in Django
While there are different ways to specify what should be rendered what should server return when ajax request is performed, using yesno template filter can be simplest. This can be especially useful in situations when using without javascript should fail gracefully or when working with existing views. {% extends request.is_ajax|yesno:“base_ajax.html,base.html” %} For this to work, django.core.context_processors.request should be installed in TEMPLATE_CONTEXT_PROCESSORS. -
Caching websites with Django and Memcached…
… memcached installation, django configuration and how to use it for your website After Caching web sites and web applications and When to use caching for web sites its time for a little sample. This sample shows the usage of Memcached for server-side application cache. The installation part is taken from my Ubuntu so it [...] -
How to create Sphinx docs the Python / Github / Read the Docs way
This is a full walkthrough of how to document a Python package, using https://github.com/audreyr/django-startcbv as the sample package to be documented. It probably works for non-Python packages too. Follow along with documenting a Python package of your own. Or try it with one of those poor, undocumented, lonely Python packages out there! At the command line: 1 2 3 4 pip install Sphinx==1.0.7 (or whatever the latest version is)mkdir docscd docssphinx-quickstart Enter something like the following at the prompts: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > Root path for the documentation [.]: > Separate source and build directories (y/N) [n]: > Name prefix for templates and static dir [_]: > Project name: django-startcbv> Author name(s): Audrey Roy> Project version: 0.1> Project release [0.1]: > Source file suffix [.rst]:> Name of your master document (without suffix) [index]: > autodoc: automatically insert docstrings from modules (y/N) [n]: y> doctest: automatically test code snippets in doctest blocks (y/N) [n]: > intersphinx: link between Sphinx documentation of different projects (y/N) [n]: > todo: write "todo" entries that can be shown or hidden on build (y/N) [n]: > coverage: checks for documentation coverage … -
When to use caching for web sites …
… five major question to ask yourself before using cache After we learned about Why, Where, What and How of caching web sites now it is time to see when to use it. The application cache is mainly used for speeding up and/or decreasing the load of frequently executed and(but not necessary) heavy resource using [...] -
Controlling iTunes from Python
<a href="http://www.flickr.com/photos/uninen/2448444839/" title="django-tunes by Uninen, on Flickr"><img src="http://farm4.static.flickr.com/3127/2448444839_83b611b31e_m.jpg" width="180" height="240" alt="django-tunes" style="float: right; border: 1px solid blue;"></a><a href="http://www.flickr.com/photos/uninen/2448444839/">Back in 2008</a> I stumbled on then new API on Mac OS X called <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/Introduction/Introduction.html">Scripting Bridge</a> that enables easy controlling of Cocoa apps (like iTunes) from scripting languages like Python. I wrote simple proof-of-concept Django app that turned my iPod touch into a remote control. It was cool, even though it didn't do very much. Now there's of course native iOS apps for this but I was somewhat surprised that there are still not much code for controlling iTunes via Web. I misplaced my original code so I decided to write it again -- just for fun. So here's a working class for controlling iTunes, in 58 lines of Python: ```python # -*- coding: utf-8 -*- from Foundation import * from ScriptingBridge import * class iTunes(object): """ A helper class for interacting with iTunes on Mac OS X via Scripting Bridge framework. To use this, launch iTunes and make sure a playlist or an album is ready. Usage: >>> player = iTunes() >>> player.status 'playing' >>> player.current_track u'Maison Rilax' >>> player.current_album u'Maison Rilax' >>> player.current_artist u'Lemonator' >>> player.pause() >>> player.status 'paused' >>> … -
Controlling iTunes from Python
Back in the day I wrote a Django app for controlling iTunes from Python. I lost the code and now I wrote it again. This time the proof-of-concept can be downloaded from BitBucket. -
FeinCMS and Fixtures: Check your trees
A short while ago, I finished my first FeinCMS website. While building the website, I was surprised by the way the tree of pages, subpages, subsubpages and so on, is being saved into the database. FeinCMS turned out to be using something called 'Modified Pre-order Tree Traversal'. Google or Bing or whatever for 'MPTT' and you will find out how it works, if you don't know it already. It seems I wasn't paying a lot of attention in mathematics classes, because all my colleagues seemed to know about its existence.Anyway, a FeinCMS page's location in a tree will be stored in the database, using a tree_id, level (0 being the top level, 1 the row beneath and so on), parent_id and lft and rght. Lft and rght are obviously the numbers left and right of the tree entry, following the MPTT principle. If you somehow want to upset the tree and FeinCMS with it, all you have to do is change one of the lft or rght numbers in the database.This totally failed to bubble into my mind when I heard about a FeinCMS page that was not displaying. Confused, I tried to reproduce the bug, without result. After a while trying and … -
Debugging Nginx and Django: Viewing HTTP headers in Google Chrome
It seems like every time I setup a new Django project, I spend an inordinate amount of time getting the site and admin media (IMG, CSS, JS) to display correctly in my templates. It doesn’t help that I haven’t standardized on a best-practices Django layout. Dreamhost shared servers require one site structure while the Linode StackScript I use (thanks Filip) suggests another. A move from Django 1.2 to 1.3 hasn’t helped either. On my home development environment (Debian in VirtualBox on Windows), I use Nginx to serve static media for my Django development server. Although this improves my dev server performance, it complicates the setup of a new environment. Recently, I was struggling to get Nginx in front of Django for a new project. To help with debugging, I wanted to see the headers returned by Nginx. My Nginx configuration adds a “X-Static” header which returns a “hit” or “miss” to indicate if Nginx served the media. To see the HTTP headers in Google Chrome, first pull up the Developer Tools pane (Control-Shift-i or Tools > Developer tools): Next, click the “Network” button in the top row and then the page url in the left pane: You can now see … -
Tôi bắt đầu học Django
Tôi chưa bao giờ học Python, cũng đã có mấy dịp định học thêm Python nhưng vẫn chưa lần nào bắt đầu được. Tôi mới chỉ biết Python là ngôn ngữ lập trình hướng đối tượng triệt để, nôm na dễ hiểu đó là cái gì trong Python cũng là đối tượng hết.Dịp này công ty có project về Django nên tôi cũng được join để làm một số task nho nhỏ. Trước đây khi tìm hiểu về một số web framework thì cũng đã biết đến Django nhưng chưa lần nào đọc kỹ và develop trên nó cả. Có lần cũng thử tìm hiểu Plone nhưng hoa hết cả mắt, đau hết cả đầu vì phải chưa gì đã vấp phải mấy khái niệm mới nào là egg, nào là bunches,...Học Django lần này lại khác vì bây giờ tôi làm việc chủ yếu ở môi trường Ubuntu và bên cạnh có nhiều cao thủ Python và Django nên có gì lơ mơ là hỏi luôn thành ra mọi việc trở nên suôn sẻ hơn. Các bước học "mỳ ăn liền" được diễn ra chóng vánhĐọc hướng dẫn và cài đặt Django trên UbuntuCài đặt Django với Apache và … -
PlushCMS - simple CMS system
Quick introduction to PlushCMS - Polish simple CMS system written in Python and Django -
Django Form Snippets
Django forms are very convenient tools for Django development, but sometimes I find myself wrangling with them to get them to do what I want them to do. I’ve compiled a few simple form examples that I find useful for various form-related tasks.Say you have a model that ... -
Updated Django-powered website
Two years ago, we launched chicagodjango.com as a place where we could unapologetically geek out about Django and Python. We didn't want to be constrained to a small tech section on our main company site (aka the Mother Ship) imagescape.com.It was campy, it was fun and ... -
Chicago Djangonauts, reanimated
Having scheduled the first meeting of the reanimated Chicago Djangonauts, I didn't know what to expect. There were a number of RSVPs on Facebook and a couple through the chicagodjango.com site, but you never know.We ordered three cases of beer from our favorite brewer and 13 pizzas ... -
PyCon, Django in Chicago and general musings
For the fourth year in a row, we have just completed our sponsorship of PyCon. Each time I return to the office after the conference ends, I am filled with a particular energy. This year that energy is more pronounced. In many ways, our day-to-day work is done in relative ... -
Security for Mobile Applications
Imaginary Landscape has been putting significant effort into developing usable and secure mobile websites. Understanding the context of a mobile user is the first step in developing security protocols to protect mobile access and information. A new blog posting on the Imaginary Landscape main website describes how we approach mobile ... -
Mobile Web Development with Django
If you've ever looked into creating your first Django project targeted at mobile devices, you were probably quick to realize that there is no be all, end all solution. Mobile development decisions have to be made with regards to handheld device detection, redirects, how to deal with desktop vs ... -
Magic Links
The first time I used the new link attachment tool found on sites like Facebook, I thought I had experienced something magical. After pasting an external webpage URL into my wall-post form, an image, page title, and page description of the linked webpage appeared beneath my post as though out ... -
Crazy about DjangoCMS
The more we dig into DjangoCMS, the more we like it. Already, we have adopted it for a number of client sites as well as internal sites. We are extending it to handle more complex presentations and it is working great.Its simple interface belies its sophistication, when configured well ... -
Our Django Server Setup: How and Why
One of the most important decisions you make in the process of building a new Django application is what software stack you use to serve it to the world. You're not lacking for options: people run Django on Apache, lighty, nginx, and Cherokee. You also need to decide how ... -
Top 5 Favorite Django Modules
Of all the Django modules that are out there, several stand out as ones that I keep coming back to. These are some of my favorites: 1) Django Debug Toolbar - http://robhudson.github.com/django-debug-toolbar/ Django Debug Toolbar is an extremely useful Django application for debugging a site from “Django ... -
Django Permission TemplateTag
In a previous post, I wrote about a way to keep track of user permissions on a model instance. For example, I suggested that each model have a permissions subclass that could be instantiated with a user instance passed as a constructor argument. Methods on that permissions class could then be called to determine if that user has permission to perform various actions. I also suggested that the threadlocals module could then be used to pass in the user instance to the permissions object in the Django template. However, from various readings, I get the impression that threadlocals may not be the best thing for passing arguments in a template function. Therefore, I decided to use a more traditional route of creating a template tag to do something similar. I created a template tag that lets you surround a block of HTML code to hide or show the contents based on the return value of the permission function. The tag below basically says, "if the logged in user has 'can_edit_group' permission on the given 'group' object instance, then display the Edit link". Reference the original post for details.In the Django template{% load permission_tags %}{% permission request.user can_edit_group on group … -
Like QuerySets, but crazier
I have a crazy QuerySet idea. Imagine we have this: class Task(models.Model): foo = models.CharField() class TaskStatus(models.Model): task = models.ForeignKey(Task) user = models.ForeignKey('auth.User') status = models.CharField(default='not-done') class Meta: unique_together = ('task', 'user') Now imagine we're listing Task.objects.all() on a page. We need to show the user's status for each task, so we do something like this: b_list = []for a in A.objects.all(): b_list.append(a.b_set.get_or_create(user=request.user)) That sucks because it's doing an extra db query for each object. We can work around that problem, but this also sucks because we're sort of needlessly creating new records when we don't need them. If the TaskStatus is being created with a default status, and we know that's what it will be because we're creating it, couldn't we just assume that status if there's no TaskStatus object and skip the creation? Yes, we could probably do that too. But now our code's going to look a little messier. I won't both writing it out, but you can imagine, right? Here's my crazy idea: Write a manager method that returns a custom QuerySet subclass that will do something like this internally: def get_for_user(self, user); tasks = Task.objects.all() task_status = dict([(ts.pk, ts) for ts in self.get_query_set().filter(user=user)]) for task in … -
Quick update on django-relationships
With the 0.3.0 release of django-relationships, I've made a couple backwards-incompatible changes which I thought I'd mention.