Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Mixing OpenID into Django's authentication system
NOTE: This code is now outdated, and it's certainly not the best way to do OpenID in Django. I recommend you take a look at django-authopenid, a fantastic registration system that combines Django's authentication framework with OpenID sign-in. Ross, 17th April 2008 According to the OpenID website, from a consumers … -
Validating a Username via jQuery with Ajax
It all starts when John hits your website and clicks the big 'Register' link. John types his name, 'John' into the username box, and hands over his e-mail address and password (unless you're cool and hip, and you let him sign up using his OpenID) and hit 'Submit', just like every other website he's signed up to in the past. Except this time, somebody else called John (what are the chances, eh?) has already signed up using that username, so after waiting a few seconds John sees an error message asking him to select another username. He types a new username and tries 'Submit' again, unsure as to whether his new selection will be suitable. So we fix this problem easily - we tell your users, while they're entering their username, whether their selection is available. To achieve this we're going to use jQuery with it's fantastic Ajax support. To get started, we create a simple view in Django that confirms the presence of a given username. This view will be accessible at /check_username/; and will expect a username via a GET paramater. def checkusername(request): from django.contrib.auth.models import User from django.http import HttpResponse username = request.POST.get('username', False) if username: u … -
Validating a Username via jQuery with Ajax
It all starts when John hits your website and clicks the big 'Register' link. John types his name, 'John' into the username box, and hands over his e-mail address and password (unless you're cool and hip, and you let him sign up using his OpenID) and hit 'Submit', just like … -
Managing local settings in Django
Sometimes it is nice to be able to configure specific Django settings for a single host and not get tons of conflicts the next time you do svn up. I personally solve this by exploiting that the Django settings.py is nothing but Python code. At the last line of the file I do a: from local_settings import * That is, way I do a relative import from local_settings.py and gets every global symbol mixed into the current namespace, allowing me to overwrite every option. An example could be to configure the global settings.py to use sqlite as a database backend for the project, but in the production environment overwrite the DATABASE_* options in the local_settings.py. This goes as well for caching - not many developers run a PostgreSQL and memcached on their laptop. To make sure that local_settings.py never is committed to the repo (and maybe compromising database passwords), it is a good idea to add it to the Subversion property svn:ignore: svn propset svn:ignore local_settings.py /path/to/your/project Furthermore, I usually put up a local_settings.py.dist with a couple of commented out examples for the developers of what could be done here. -
Facebook/Washington Post, Performance Tuning
This final post about my group's work (at Washington Post.Newsweek Interactive) on our Facebook Platform app The Compass is long overdue. But now the time has come! Let's talk Postgresql and Apache performance.In the first two posts on this subject, I wrote about the Facebook Platform itself and the Compass' architecture. In this post, we'll look at some of the challenges we encountered while serving the app and areas we focused on to improve our Postgresql and Apache performance.NOTE: All of this is anecdotal, based on my experience with this app. I'm no performance guru and don't hold myself up as such. I think, too, different applications have different needs, and the requirements of something like Facebook could not be optimal for other situations.Caching LimitationsAs I mentioned last time, all of FBML we load into a profile is cached and served by Facebook, but the hits to our application pages are hits to our servers as well. The first thing that comes to mind with Django is, "well, make sure you have caching enabled." There are a couple reasons why this doesn't work as well as one would like.First, the caching for a Django site is bypassed when the request … -
Django no Ubuntu
Foi criado um package para o Django no Ubuntu [1]. Com isso é possível instalar o Django no Ubuntu com apenas um comando: sudo apt-get install python-djangoSimples, fácil e rápido como tudo na vida deve ser![1] - http://packages.ubuntu.com/feisty-backports/python/python-django -
DjangoSites - We Want YOU!
I've just approved another batch of sites bringing the total to 260. I've also had to delete a few sites that were submitted due to a number of reasons: A handful were submitted that are obviously not Django (providing your link as /index.php is a give away) and a few have been submitted that are inaccessible URL's. If you've got a website built with Django, we'd love for you to submit it. There are about 600-700 sites listed on the wiki page, if we can get most of those moved over to DjangoSites.org it'd be fantastic. It's a great way to show off what's out there in the wild that's powered by Django, and a great way to get feedback on your sites. For those learning Django, it's also a great way to see how others have built their sites. Our listing of sites with publicly available source is growing every week, and is a great way to view how different problems have been tackled. In the meantime, maddiin and I are working on a repository for Django-powered applications. There are plenty of projects out there (especially on Google Code), however having listed together in one place can only be … -
DjangoSites - We Want YOU!
I've just approved another batch of sites bringing the total to 260. I've also had to delete a few sites that were submitted due to a number of reasons: A handful were submitted that are obviously not Django (providing your link as /index.php is a give away) and a … -
Django na PyCon Brasil
Dia 30 de agosto a 1 de setembro na SOCIESC em Joinville - Santa Catarina, acontecerá o maior encontro de desenvolvedores, amantes e simpatizantes pela linguagem de programação Python o PyCon Brasil.Esse ano a PyCon Brasil [1] contará com duas palestras e um treinamento básico sobre Django. Aliás o treinamento, será ministrado por este singelo djanger que vos escreve (eu). Essa participação de djangers na PyCon é uma avanço, já que será o primeiro PyCon Brasil que conta com palestras e treinamentos relacionados ao Django.O Django é um dos frameworks para desenvolvimento rápido para web em Python com mais ascensão no Brasil. Devido ao crescimento da comunidade aqui no país, que começou a se formar em dezembro do ano passado com uma lista de discussão no google groups [2]. Um sintoma do crescimento da comunidade Django aqui no Brasil é a participação de djangers brasileiros no planet oficial do django, além das participações de brasileiros na listas de discussões oficiais do Django [3].Se você curte Python, Django, quer aprender mais sobre Python, Django, Zope, conhecer os amantes dessa linguagem e saber o que a galera anda fazendo com Python aqui no Brasil. Comece a arrumar as suas malas, ainda há … -
New WTForm release
I have just published a new version of WTForm, my Django newforms addon to allow for grid form layouts (using YUI) and extra classes for more specific and easier CSS styling. There was a problem when using WTForm with form_for_model or form_for_instance resulting in not getting any fields in the generated form class. This should be fixed now. The djangosnippets page for WTForm now also includes a link for a screenshot to see an example of a form using grids and some other neat CSS styling by my colleague Oscar. -
Django Master Class
Jeremy Dunck, Jacob Kaplan-Moss, Simon Willison disponibilizaram online a apresentação deles sobre Django feita na OSCON desse ano.Essa apresentação trata de técnicas avançadas em Django abordando: o uso de testes unitários, OpenID, criação de Fields Customizados, middleware, signal's, ajax entre outros temas.Essa apresentação é parada obrigatória para quem quer aprofundar seus conhecimentos em Django.Para quem quiser conferir é só acessar: http://toys.jacobian.org/presentations/2007/oscon/tutorial/ -
Uploading images to a dynamic path with Django
Update: There’s a new method you should try first. See: Dynamic upload paths in Django Django makes it easy to upload images by adding an ImageField to your model. The images are uploaded to your media path in a subdirectory specified with the upload_to parameter which can contain a date/time pattern like %Y/%m/%d. class Photo(models.Model): [...] -
Django is for everything!
To those who think Django is for content only, here are some of the sites we (at Cuker Design) have ... -
Updated Django Shortucts
My code was checked in as of Revision 5796, giving get_object_or_404 and get_list_or_404 the ability to accept QuerySets. Previously, these ... -
Yikes! Stockphoto on Django status update!
The last couple of days I have been seeing a renewed interest in Stockphoto , my basic, minimalist photo gallery ... -
Yikes! Stockphoto on Django status update!
The last couple of days I have been seeing a renewed interest in Stockphoto, my basic, minimalist photo gallery application for Django. At the time, I wondered why, since I haven't updated Stockphoto in the last year, nor made any announcements associated with it. Then, I saw that it had been mentioned in the Django status update on July 22. This is just a little notice on stockphoto's status. Stockphoto 0.2 has quite a few known bugs. I have to-do items for all of them in my personal organization system, most of them with contributed patches. I've just been too busy in my life to integrate all of these fixes and package them into a release. I want to do better and get two releases out the door soonish. So here's the release plan: Stockphoto 0.2.1, soonish. Will fix all outstanding bugs that I know about. Stockphoto 0.3, later. Will include changes to the models to allow slug-based rather than id-based URLs, and some conveniences for template designers. Please bear with me -- if you are in desperate need of a full-featured Django photogallery in the very near future, you will probably want to write it yourself, possibly looking at … -
Web templating systems: be opinionated enough, but no more.
There's some current discussion in the Django community on templating systems on Jacob Kaplan-Moss's website and elsewhere. I agree with ... -
Web templating systems: be opinionated enough, but no more.
There's some current discussion in the Django community on templating systems on Jacob Kaplan-Moss's website and elsewhere. I agree with the general argument. There is a rather fine line between putting too much power into the templating language, so that it either becomes a programming language in its own right, or simply a means of embedding primary-language code in the templates, and putting in too little, so that you can't do more than variable substitution. That's not a big insight in and of itself. I think almost everyone knows this by now. What I think is significant is this: Django's templating system hits the sweet spot for web templating. Through a combination of good taste and (probably) luck, the Django developers have produced a templating system that strongly encourages web developers to put their controller logic and their view logic in the right place. Django's templating system is just tightly coupled enough to make people think twice before using something else. You certainly can use other view technologies, and it's not really hard to do so (just do everything your other template system to produce a string or a file-like object representing the content of the response, and pass it … -
Seasoning Templates
I’m a food geek. I spend my free time contemplating recipes. I bore my friends by talking about the Maillard reaction and annoy them by saying things like, “did you know that cheesecakes aren’t actually cakes at all?” I wonder about the techniques for replacing chemical with organic leavening and vice versa. I watch the Food Network, and Alton Brown is my hero. I cook a lot, of course, and I’ve gotten pretty good at it. -
Announcing django-localdates
localdates is a django app that brings local date presentation to django, by providing custom date filters that can use local-flavored format strings. Reasoning I'm Greek, and the greek language is a lot more complicated than english. There are genders and cases and more stuff that change the suffixes of the words, depending on the use. This is very annoying when trying to create a multilingual site, or when using a multilingual framework like Django. As Malcolm Tredinnick , one of Django's lead developers has put it: (1) The fundamental reason this (date formats) is a problem at all is because we are attempting to construct grammatical sentences out of short fragments. A guiding principle in creating translatable strings is to create complete strings as often as possible because constructing sentences from fragments is very locale specific. From: the relevant discussion, continued from ticket 4147 One of the most visible aspects of this problem is, as you may have guessed, date presentation. Date is a very common function in most sites, and having it appear correctly is a major issue. Up to now, if you wanted a date to look correct in Greek, the only option was to use an … -
Die, Marker Felt, Die!
Like everyone else, I got sick of looking at Marker Felt on my iPhone. So I did something about it. OK, so it wasn’t a huge amount of work; I mostly pieced together the cool shit that others are doing with the iPhone these days. If you, too, would like to (possibly) void your warranty and try it out, here’s the skinny: Follow the custom ringtone instructions (and install ringtones, if you like) through the end of step 13 (i. -
django unicode integration: fix for venus djando template
I just upgraded django tree which recently merged in the unicode support. This immediately broke django templates for venus. Here is what you need to change in planet/shell/dj.py to account for new django changes: 43c43,46 < f.write(t.render(context)) --- > ss = t.render(context) > if isinstance(ss,unicode): > ss=ss.encode('utf-8') > f.write(ss) This is probably due to render [...] -
Creating a portable development environment
I spend much time on other people's computers - I'd like to be able to hack for 30 minutes on an idea, but unfortunately, it isn't easy. I have to download and install numerous software packages, like python, django, subversion, an SSH client etc. So I decided to put all that in a flash drive and take it around with me. Here is what it includes: Portable Python (python + django) Subversion - standalone binaries Notepad2 μTorrent Mac-on-a-stick Portable apps suite that includes: Putty Firefox OpenOffice 7-Zip Gaim Clamwin Sudoku VLC player Not too shabby! I'll play around with it and I'll update this post. Of course the ultimate test is to use it on another computer, and that'll happen next week. Comments -
Supercharging get_next_by_FOO
There is a neat piece of functionality in Django that will allow you to traverse your object graph by date: Get next or previous by FOO, where FOO is a Date or DateTime field: For every DateField and DateTimeField that does not have null=True, the object will have get_next_by_FOO() and get_previous_by_FOO() methods, where FOO is the name of the field. This returns the next and previous object with respect to the date field, raising the appropriate DoesNotExist exception when appropriate... However, these methods use the default manager, that may be not what one wants. Don't override You could override these methods, but admin and many other contrib applications rely on them to return every single object, so you'd break them. Maybe this should be fixed in the trunk by specifying two default managers: one named all and another one named objects. The first could be used by admin-like applications, like admin or databrowse, and the other for applications that display stuff to users. Anyway, until this is done, we can't override, so instead we'll add new methods. DIY Fortunately, we can reuse the functionality of these nice methods, since they accept filter arguments. But, in the principle of DRY, duplicating … -
Dear Adobe
Dear Adobe – Acrobat sucks gigantic mountain-goat testicles. Everything about it from the installer to the interface to its performance seems designed to be as user-hostile as possible. Everyone involved in this project should be ashamed. That is all.