Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
benchmarking Django Queue Service
I took some time this afternoon to benchmark out the work we’ve been doing with the Django Queue Service. We haven’t done anything to optimize it, and we’re starting to push in some code to make it fully support REST … Continue reading → -
6 Weeks with Ruby
When I left Cuker Design to work for Slicehost I made the transition from Django to Ruby on Rails. Some Ruby conventions are similar to Python, but many threw me off a bit. Here's what I discovered after 6 weeks with Ruby and Rails. -
Bug patches for django-voting and django-tagging
As part of my top-secret Django project, I’ve enlisted the help of the django-voting and django-tagging packages to provide rating and tagging, respectively, to my models. These work wonders and serve their purpose to a T, however, I’ve come across a couple small bugs that I wanted to document here, in addition to the bug [...] -
Wanted - Engaged Djangonauts
I've spent the last year or so building a Django-powered bridal gift registry service. It allows you to easily list desired gifts in a simple online format, for your guests to select and purchase for you. It works pretty well - my wife let me use it for our own wedding, afterall. It's also stood up to a half-dozen other weddings, who have all provided fantastic feedback which I've put into place. I'm just about ready for launch, but I'd like to do a final round of live testing. So, I'm opening it up to Django users worldwide. The criteria? Be getting married in the short-term future Be prepared to provide feedback Be prepared to use public beta software (However, I believe it's stable enough!) Have a [wife|husband]-to-be who is happy to be involved :) In return I'll provide a premium account (value: $40AUD) for you to use from day one. Interested? Just e-mail me at ross at this domain and I'll provide a signup URL. You're welcome to sign up and check it out before committing to using it for your wedding, of course - however if you choose not to use it, I'd love to know what WAF … -
Wanted - Engaged Djangonauts
I've spent the last year or so building a Django-powered bridal gift registry service. It allows you to easily list desired gifts in a simple online format, for your guests to select and purchase for you. It works pretty well - my wife let me use it for our own wedding … -
DjangoPoweredSites Grows Up
After some e-mail discussions with Jacob Kaplan-Moss from the Django team, I've moved all of the sites listed on the old DjangoPoweredSites wiki page to Djangosites.org. It took a fair bit of time to weed out some not-working pages and expired domains (which have, of course, been purchased by spammers and link farmers), and a small investment in extra WebThumb credits to allow me to take screenshots of a fresh 500+ websites, but I got there in the end. We'll now be closing the DjangoPoweredSites wiki page for good, as it has become redundant and is not the best way to peruse 800+ websites. What we're left with is a fantastic directory of websites powered by Django. I'll be putting together a 'Featured' list shortly, but in the meantime I need a little bit of help from the community. All sites scraped from the wiki page are currently unowned. I encourage you to check out the list of unclaimed websites, and e-mail me to let me know which sites are yours so you can receive due credit. There are some great websites listed there, so it'd be fantastic to be able to show off who built them. Thanks to Jacob … -
DjangoPoweredSites Grows Up
After some e-mail discussions with Jacob Kaplan-Moss from the Django team, I've moved all of the sites listed on the old DjangoPoweredSites wiki page to Djangosites.org. It took a fair bit of time to weed out some not-working pages and expired domains (which have, of course, been purchased by … -
Django Queue Service
Work has been continuing apace on the Django Queue Service, mostly through the efforts of Rajesh and Marcus who have really done an outstanding job of filling in the holes in testing and structure for the application to make it … Continue reading → -
Multiple File Uploads in Django
As part of yet-to-be-announced project, I’m working with Django. After only a couple days, I’ve been able to produce some pretty cool results. One of the requirements that I have is that a user be able to upload a bunch of files when editing a form. Using Django’s newforms package, I was able to quickly [...] -
Easy Multi-Part E-Mails with Django
Every time I send e-mail with Django I seem to do it slightly differently, especially when it comes to sending HTML-based emails. So, I did what any good Djangonaut does and wrote a quick function that wraps up sending of a multi-part HTML / Text e-mail from templates you create. Firstly, create your e-mail templates. You'll need both a HTML and a plain-text template; for the HTML template I strongly recommend the use of Premailer, which puts all CSS definitions inline. Here's a sample HTML template - as it would come out of Premailer. We'll pretend it's in the emails template directory, with a name of newsite.html. <h1 style='font: Arial; font-weight: bold; font-size: 15pt; color: #006;'>Thanks!</h1> <p style='font: Arial,Helvetica; size: 10pt;'>Hello, {{ username }}.</p> <p style='font: Arial,Helvetica; size: 10pt;'>Thank you for submitting your website, titled <strong>{{ title }}</strong>, to our listing.</p> <p style='font: Arial,Helvetica; size: 10pt;'>We'll verify it, take a screenshot, and publish it within the next few days.</p> <p style='font: Arial,Helvetica; size: 10pt;'>Regards,</p> <p style='font: Arial,Helvetica; size: 10pt;'><em>Your Favourite Webmaster.</em></p> And here's that same e-mail, in plain-text format - also in the e-mails folder, called newsite.txt. Hello, {{ username }}. Thank you for submitting your website, titled '{{ title … -
Easy Multi-Part E-Mails with Django
Every time I send e-mail with Django I seem to do it slightly differently, especially when it comes to sending HTML-based emails. So, I did what any good Djangonaut does and wrote a quick function that wraps up sending of a multi-part HTML / Text e-mail from templates you create. Firstly … -
Using the extra() QuerySet modifier in Django for WeGoEat
Since I actually used this method to reduce the number of Update:”explicit” SQL calls made in WeGoEat, I figured I’d write a little blog explaining the context in which it was used, and maybe, just maybe, it’ll help shed some light on how others can take advantage of this neat little function. Background As a Django “proof-of-concept”, I’m working on a local restaurant review site for my home state of Hawai`i. (I actually just released it yesterday). For each restaurant, I want to be able to calculate the average of all reviews and display this listing in a paginated view. (Yes, I do realize there’s no average rating, but that has to do with there being no users. ;P). The Problem Having a serious “wtf was I thinking moment”, I initially wrote a Restaurant model function that returned the average (review) rating for each restaurant instance. Little did I realize that when I actually displayed the restaurant’s average reviews, I would be making an additional SQL avg() call for every restaurant. Though I’m paging “n” records at a time, this function added an additional “n” SQL calls for every view that contained a restaurant listing, just to name a few. … -
Of the Web
I’ll have more notes about CouchDB later tonight. First, though, I want to step back and look at the big picture. A few months ago, Bill de hÓra wrote that “a framework like Django or Rails is purpose-built for the Web” (as opposed to old-school tools that try to pretend the Web doesn’t exist – I’m looking at you, ASP). It doesn’t sound like much, but to me this is the best possible compliment Django could be given. -
CouchDB first impressions
I’m playing with CouchDB tonight. Some first thoughts, as they occur to me: The build process was very easy. I already had Erlang and all the standard automake/autoconf crap installed, so it was just a matter of installing something called icu and going from there. Something like 10 minutes from svn checkout to relaxing. Anything I can poke at with curl is pretty damn cool. Wow, I can just chuck arbitrary JSON objects up at this thing and it’ll store it. -
SQLAlchemy no Django com tranquil
Muitos programadores reclamam a falta de integração do Django com o SQLAlchemy. Há até um branch no projeto do Django para realizar essa integração, mas esse branch anda meio parado no momento.Em paralelo a isso foi criado um projeto chamado tranquil, que tem por objetivo integrar o SQLAlchemy no Django.As features mais legais desse projeto implementado até o momento são:Usar tables, objects e mapper objects do SQLAlchemy no DjangoManipular models do Django como se fossem objetos do SQLAchemyO projeto está no início ainda, mas será bem interessante quando for possível usar o Elixir no Django.O site do projeto é: http://code.google.com/p/tranquil/ -
Calling all (Django) programmers… (I need advice)
Update According to Max, it’s against Facebook’s TOS to cache the data. I’ve totally must’ve skipped over it in the TOS… ok, fine… I admit, I didn’t even read it. Thanks Max! And to think this response was less than an hour after my post! Yay, community. In any case, this problem is still relevant to many a graph-structured sites. Comment on! Since I don’t know of many techies in Hawaii, I figured I would post a blog in hopes of attracting a solution from the akamai Django community. The Background I’m currently writing a Facebook application in Django (which I’ll be blogging about later). The Problem I want to be able to programatically tell if you’ve updated your friends in Facebook. Basically, at the end of the day, Facebook provides an API call that allows you to retrieve a list of uid’s that represent your ‘friends’. I’m planning to cache this data within my own system. I was wondering how Pythonic people would solve the following: Is there a data type or algorithm (or combination thereof) I can use to compare the returned uids with my uid data cache? This comparison algorithm will tell me if you’ve added or … -
Getting started with WTForm
I found out that Clint mentioned the little pet project of mine on his weekly roundup of happenings in the Django world. So I thought this would be a great time to tell the world a bit more about the project, and do a little practical example for the readers. What does WTForm do? Basically, WTForm does the following: Widget and Field type as class names on field container div for easier CSS styling. (and a required indicator as well) Allows you to group your form fields and columns in fieldsets. Allows you to group your form fields and fieldsets in columns. (oh - the redunancy!) With regard to the last two points, WTForm allows for "infinite" nested structures. Enables you to insert arbitrary HTML snippets in the middle of your form. Project background The project was started as small hack when we (at GMTA) needed another output scheme (namely using div tags) and needed to allow for easier CSS styling using classes on every container div tag. The problem is that the "vanilla" newforms will output the form without any classes indicating whether the field is required or what kind of field we are working with. This resulted in … -
Lançado o e-book Diabetes na Prática Clínica
Ontem (8/10) foi o lançamento oficial do e-book "Diabetes na Prática Clínica". Esse e-book é um projeto pioneiro lançado pela Sociedade Brasileira de Diabetes para estimular a educação médica continuada.Toda a parte de programação e banco de dados projeto foi desenvolvido por mim, e eu utilizei o Django como ferramenta para o desenvolvimento. E o layout e desenvolvimento visual foi feito pelo Eduardo Frick.O mais interessante desse projeto foi a utilização do Django. Em todos os trabalhos que fiz em parceria com o Eduardo Frick sempre utilizamos PHP. Mas, como um bom pythonista e djanger, convenci o Eduardo a trabalharmos com Django nesse projeto e ele me deu seu voto de confiança.Essa escolha foi arriscada, mas eficaz! Com o Django foi possível solucionar problemas complexos de maneira simples e rápida.Nesse projeto eu usei e abusei do que mais gosto do Django: o newforms, ferramenta de serialização, template tags e template filters deixando de lado as generic views e o admin do Django. Fiz essa escolha pela necessidade de fazer um painel de administração bem específico.Usei também o Prototype para facilitar o trabalho com AJAX e Javascript.O resultado foi um sucesso e espero que vocês gostem! -
Including variables as templates
To manage the website content in a flexible way it's practical to have some portions of some pages generated from variables created as FlatPages. For example, in a frontpage I have a "featured item" section which renders a flatpage variable. def frontpage(request): fp = FlatPage.objects.get(url='featured') return render_to_response('frontpage.html', {'fp':fp }) then in the template ...<div id="featured">{{ fp.content }}</div> ... But sometimes it would also be nice to put some template tags inside those flatpages. Django does not seem to provide a tag for such task (most probably because it can be a bad idea from the security point of view), but the ssi tag does exactly the same thing for files in the filesystem. Based on ssi, the code bellow defines a new tag that includes the content of a variable as a template. def do_templatevar(parser, token): bits = token.contents.split() if len(bits) != 2: raise TemplateSyntaxError, "%s tag takes one argument" % bits[0] return TemplateVarNode(parser.compile_filter(bits[1])) register.tag('templatevar', do_templatevar) class TemplateVarNode(Node): def __init__(self, content): self.content = content def render(self, context): content = self.content.resolve(context) try: t = Template(content) return t.render(context) except TemplateSyntaxError, e: if settings.DEBUG: return "[Included template had syntax error: %s]" % e else: return '' # Fail silently Now I can put … -
Displaying stars (with rounding) as a Django templatetag
Since my last post was quite popular (by my simple blogging standards), I’ve decided to post another Django snippet that I’ve used while coding WeGoEat. (I know, I know… one of these days I’ll finish. I’ve just been really, really lazy busy.) After reading Leah’s blog (of Pownce fame) about “rounding to the nearest half”, I was immediately struck by two sobering realities: I would need that exact same algorithm for my current site. A few years out of grad school, and I couldn’t even begin to fathom a solution. Thank you, Internet. In any case, I figured I’d wrap my solution into a template tag that people could use/steal/copy. Here’s a generated test page that illustrates what my template tag would display. You can even customize the display a bit: I know, I know… I can do a lot better. In any case, here’s the code snippet that I placed in a file called show_stars.py: import math from django.template import Library, Node, TemplateSyntaxError, VariableDoesNotExist, resolve_variable from django.conf import settings register = Library() IMG_TEMPLATE = '<img src="%s" alt="%s"/>' PATH_TO_WHOLE_STAR = IMG_TEMPLATE % (settings.MEDIA_URL + 'img/stars/star.png', "Whole Star") PATH_TO_THREE_QUARTER_STAR = IMG_TEMPLATE % (settings.MEDIA_URL + 'img/stars/three-quarter.png', "3/4 Star") … -
Django - Multiple Aliases for a Single Website
In these days of cheap domains, it's often desirable to own multiple domains for a single website. You've probably got each of the .com, .net and .org domain names, along with a country-specific domain. You want each of these to present exactly the same website to the world, but good design says that each web page should have one, and exactly one, URL. So what's the best way to serve this up without having an Apache config for each domain? I've come across this whilst building a website recently whereby the primary domain is mydomain.com.au, while I've got secondary domains in other popular TLD's to try and reduce domain squatting and the like. One option is to configure an Apache virtual host for each domain, which serves up a static redirect. Another is to have Apache aliases for the main host, so each of the domains serves up the same content. This works, but leaves each page with multiple URL's. My solution is to set up Apache aliases, and use a Django middleware to identify any requests that aren't for the main domain name, redirecting them as they're found. The middleware code I use is as follows: from django.http import … -
Django - Multiple Aliases for a Single Website
In these days of cheap domains, it's often desirable to own multiple domains for a single website. You've probably got each of the .com, .net and .org domain names, along with a country-specific domain. You want each of these to present exactly the same website to the world, but good … -
Django - A Diverse Community
Scott Barnham, one of the guys behind the recently-launched Django Gigs website, has posted some statistics from visitors to the Gigs website over the past few days. I've put together some similar stats for the Django Sites website, which has been online for a few months now. Note: All figures are from Google Analytics, and percentages are rounded to make life easier. Summary 70% of our visitors are new, 30% are repeat-business. The average visitor views 5 pages, staying on the site for 3 minutes The most popular page, with 20% of page views, is the latest additions, followed by the listing of django-powered sites with source-code available at 5% of page views. Django Developers: newcomers to the community want to see source code! Operating Systems Windows 60% Linux 21% Macintosh 18% Others 1% The operating system split is very much skewed towards Windows, almost all of the Windows users on Windows XP. It's nice to see higher-than-average (compared to my other sites) usage of Linux & Macintosh. Browsers Firefox 66% Internet Explorer 16% Safari 7% Opera 5% Others 6% No surprises here. Firefox figures are very similar to the Gigs site, with Safari & IE being a bit different. … -
Django - A Diverse Community
Scott Barnham, one of the guys behind the recently-launched Django Gigs website, has posted some statistics from visitors to the Gigs website over the past few days. I've put together some similar stats for the Django Sites website, which has been online for a few months now. Note: All figures … -
Django developers: We are the world
An informal survey of the Django community This week, Andrew and I launched the Django Gigs website to help employers find Django developers. Andrew wrote about it and thanks to the Django Community feed aggregator we had quite a few visitors in the first couple of days. It’s clear that Django is catching on and growing in popularity. The djangoproject.com site is getting close to 8 million hits each month. I thought it would be interesting to analyse my logs and see what I could tell about the Django community, or at least the section of it that read the blog and visited the Django Gigs website. Visitors 1280 unique IP addresses The number of IP addresses seems a pretty good indication of how many unique visitors we had in about two days. Platforms 510 Windows 373 Mac OS X (including 4 iPhones) 312 Linux 85 Other (mostly bots, feed aggregator sites, a handful of BSD) The platforms is a pretty even split among Windows, Mac and Linux. Which given the dominance of Windows on the desktop suggests Django is disproportionately popular with Mac OS X and Linux users. I suspect this is the case with Python in general, but …