Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django on Jython
It's on! Leo writes about his experience porting Django to Jython and there's a thread on the django-developers group too. Funny how things seem to click for a bunch of people all at once - the release of Jython 2.2 seemingly the catalyst. For my part I've been working on porting sections of Django to Jython on and off for a couple of weeks. Whilst Java is great for paying the bills, developing web applications with it is pretty slow (by comparison). My stack from bottom up looks something like this MSSQL -> {Spring: [Hibernate , Service tier]} -> Web framework. Yes, it's Enterprisey in the pejorative sense! ;) One of the web frameworks is actually Flex Data Services, which is great for RIAs but terrible where you want to bang together a quick admin app. I figured the architectural gaps between Velocity templates and the enterprise business tier I mentioned above could be filled very nicely with parts of Django, such as New Forms: Where Leo adopts a more holistic approach outside of the container, I've been fiddling around with the appealing concept of Django MVC as Struts 3.0!! Lessons Today, Django in Jython not only involves not only … -
Texas Python Regional Unconference
Just a quick announcement for all the Houston and surrounding area Python lovers out there. There is a Texas Python Regional Unconference being held in a couple weeks (Sept. 15 – 16) at the University of Houston main campus. Registration is free and as simple as adding your name to the registration wiki page. I’ll [...] -
Django vs feedparser on dates
I'm having trouble storing feedparser results in a Django model. It's all about timestamps. Feedparser returns timestamps in a standard time nine-tuple, asserting UTC. Django wants datetime objects. So, I'm trying to translate: django_timestamp = datetime.datetime.fromtimestamp(time.mktime(feedparser_timestamp)) feedparser_timestamp = django_timestamp.utctimetuple() This works fine for the majority of timestamps, but sometimes translating to datetime and back mutates the timestamp. In turn, that makes get-if-modified-since somewhat unreliable. Here are some examples, from my log file: WARNING: (2004, 11, 19, 5, 13, 31, 4, 324, 0) => datetime.datetime(2004, 11, 19, 6, 13, 31) => (2004, 11, 19, 6, 13, 31, 4, 324, 0) WARNING: (2005, 11, 2, 2, 17, 55, 2, 306, 0) => datetime.datetime(2005, 11, 2, 3, 17, 55) => (2005, 11, 2, 3, 17, 55, 2, 306, 0) WARNING: (2006, 12, 13, 0, 21, 25, 2, 347, 0) => datetime.datetime(2006, 12, 13, 1, 21, 25) => (2006, 12, 13, 1, 21, 25, 2, 347, 0) WARNING: (2004, 11, 14, 23, 55, 31, 6, 319, 0) => datetime.datetime(2004, 11, 15, 0, 55, 31) => (2004, 11, 15, 0, 55, 31, 0, 320, 0) I'm off by an hour. I smell a problem with daylight savings. I just wish I knew what to do … -
My "personal security" plan
My personal security plan Prompted by recent reading on cryptography and computer security, I’ve been rethinking my pretty lax personal security plan. Right now I’m doing a number of pretty stupid things, including reusing just a couple passwords (“high” and “low” security), using browser/keychain password remembering too much, and storing important documents (tax returns, etc.) unencrypted. A co-worker just had his laptop stolen, and I’ve realized just how screwed I could be if that happens to me. -
Of Meta Tags and Context Processors
We just launched a site that required heavy utilization of <meta> tags. The most demanding aspect of this process was ... -
Edit inline with ImageField or FileField in Django admin
Django admin lets you edit related model objects “inline”. For example when editing a Recipe you can add/eding a group of Ingredient models. Core fields for edit_inline The related model being edited inline must specify one or more “core” fields using core=True. If the core fields are filled in, the related model is added. If the core fields are empty, the related model is removed. This works great for normal objects with CharFields, etc, but not so well if you want to have images or files uploaded using inline editing. If the only core field is a FileField or ImageField, you’ll get strange behaviour like the file/image being removed when you edit an existing model in the admin. Using inline editing with ImageField or FileField In a recent project I wanted to have an item with title and description and zero or more photos. The Photo model just has an ImageField. To make it easy to edit, I wanted the photos set to edit_inline. Here’s my first attempt: class Item(models.Model): title = models.CharField(max_length=100) description = models.TextField() class Admin: pass class Photo(models.Model): item = models.ForeignKey(Item, related_name='photos', edit_inline=models.STACKED) image = models.ImageField(blank=False, upload_to='items', core=True) Notice that the ImageField in Photo has core=True to … -
iPhone says Welcome to Django
-
iPhone says Welcome to Django
-
Custom Python installation for Django on Dreamhost
Now that my MBA class is finally done for the summer, I can focus on more important things… like upgrading my Python installation on Dreamhost for my Django application. Seeing as how Dreamhost is still behind the Python times, with Python 2.4 hidden in Dreamhost obscurity, I figured I’d blog about updating your Dreamhost Python installation (and subsequent MySQLdb libraries) to Python 2.5. The very first thing I did was search Google. You know, I really don’t know how people lived pre-Googs. In any case, I found this blog posting describing exactly what I wanted to do. Thanks Ben! Since I’m not a big fan of running one large batch script people create in their blogs, I’ll break it down for the non-*nix fans out there. Before I begin, I’m assuming that you already have Django running on Dreamhost. If you’re having a “wtf” moment, make sure to stop by Jeff’s blog and read “Setting up Django on Dreamhost“. (This is how I set mine up). To follow my short tutorial, you’ll need shell access to your Dreamhost account. After ssh’ing into your Dreamhost account, you should be in your home directory (/home/username). According to the Filesystem Hierarchy Standard, the … -
Permalink decorator pt. 2
Since writing briefly about Django's permalink decorator I've had quite a few emails regarding the use of the permalink decorator and generic views. Here is what works for me... I often have the following urlconf in urls.py: urlpatterns = patterns('django.views.generic.date_based', (r'^(?P<year>d{4})/(?P<month>d{1,2})/(?P<day>w{1,2})/(?P<slug>[-w]+)/$', 'object_detail', dict(info_dict, month_format='%m')), ) And the corresponding get_absolute_url method cut straight from my class looks like this: @permalink def get_absolute_url(self): """ return absolute url of this object """ #pylint: disable-msg=E1101 return ('django.views.generic.date_based.object_detail', None, { 'year': self.create_date.year, 'month': self.create_date.strftime('%m'), 'day': self.create_date.strftime('%d'), 'slug': self.slug}) This is already well documented here and here, but I hope this extra example helps. Note: For completeness, I use Eclipse with Emacs key bindings and the Pydev plug-in with pylint activated - hence the pylint ignore directive. Posted by Cam on Mon, 20 Aug 2007 13:47:02 +1000 -
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 … -
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 point of view OpenID is "the elimination of multiple user names and passwords and a smoother, more secure, online experience. ". What it provides is a single identity for you to use at multiple websites. Instead of having a username and password for each website you peruse, you have an identity (usually a URL to your blog or an OpenID provider) that you use to login. The only password you have to remember is that of your OpenID provider - and you don't have to provide your password to any websites you visit. Simon Willison has been a fantastic campaigner for OpenID, especially for integration with Django. He's written the fantastic django-openidconsumer package which provides the framework for a Django Application to act as an OpenID consumer (that is, people login to your Django app using their OpenID). Simon's package creates a new OpenID object within your application, but is … -
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 ...