Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
EuroDjangoCon
Just a quick note to say I just registered to go to EuroDjangoCon! Head over to http://euro.djangocon.org/ to sign up for the earlybird prices! I can't wait, it's going to be Awesome. :) Hope to see you all there! -
Missing django-admin's startproject Command?
Did you just notice your "django-admin.py startproject new_project" command does nothing but to remind you to read the help docs? Well, clear your existing environment variable "DJANGO_SETTINGS_MODULE" and you'll have it again.Django takes away "startproject" command if it realizes you are already working with an existing project. Not sure what the purpose is, but its there. -
A Second Look at Inheritance and Polymorphism with Django
Previously I wrote about ways to handle polymorphism with inheritance in Django's ORM in a way that didn't require any changes to your model at all(besides adding in a mixin), today we're going to look at a way to do this that is a little more invasive and involved, but also can provide much better performance. As we saw previously with no other information we could get the correct subclass for a given object in O(k) queries, where k is the number of subclasses. This means for a queryset with n items, we would need to do O(nk) queries, not great performance, for a queryset with 10 items, and 3 subclasses we'd need to do 30 queries, which isn't really acceptable for most websites. The major problem here is that for each object we simply guess as to which subclass a given object is. However, that's a piece of information we could know concretely if we cached it for later usage, so let's start off there, we're going to be building a mixin class just like we did last time:from django.db import modelsclass InheritanceMixIn(models.Model): _class = models.CharField(max_length=100) class Meta: abstract = TrueSo now we have a simple abstract model that … -
Migrating Django models with south and converting data
I use South whenever a model needs to be changed. One thing that is not really documented in the South documentation is how to convert data. After some trial and error I found a way to use Django QuerySets to access both the old and new models to convert data. For example, I used to have two models defined like this: class Assignment(models.Model): course = models.ForeignKey(Course) name = models.CharField(max_length=100) class AssignmentEdition(models.Model): assignment = models.ForeignKey(Assignment) # ... other fields The way the assignments were defined, each edition of an assignment has the same name. I needed to change this into: class Assignment(models.Model): course = models.ForeignKey(Course) class AssignmentEdition(models.Model): assignment = models.ForeignKey(Assignment) name = models.CharField(max_length=100) # ... other fields Each edition has it’s own name. It’s still possible for editions to have the same name, but it is also possible to have a different name and still be an edition of the same assignment. During the migration I want each assignment edition to get the name of it’s assignment. One way to do this is to use SQL queries to get the names of the assignments and update the assignment edition names, but that’s not very Django-like. I want to use QuerySets. I … -
Create a Stand-alone Django Documentation Browser
I’m constantly quitting and changing browsers. I got tired of having to load up the Django Documentation. I found an easy way to keep up the Django docs by themselves. I use Fluid, a site-specific browser creator, for Google Reader, and I thought why not for this? When you launch Fluid, It asks you for a URL, a Name for the application, a location to save the application and what icon to use (it defaults to the web site’s favicon). I created my own PNG and made it the icon. Once you press the Create button, you can open the application by double clicking on it. To make the application a bit more flexible, open the preferences (command-,) and click on the Advanced icon. There you can add and change the urls that this application will go to. I changed the url to *.djangoproject.com/*. There you have it: a stand-alone browser of the Django documentation. -
7. Finishing the Weblog
This is part 7 of a series of posts on James Bennett's excellent Practical Django Projects. The table of contents and explanation can be found here Firstly, the comments framework has been re-written for 1.0. The documentation for it can be found here if you need to refer to it. That out of the way lets get into the meat of the chapter. There is now only one model for comments instead of two -
Field/column Queries in Django
Field/column Queries in Django -
My Django development environment
IDE After using a few other IDE‘s I settled down with Eclipse with Aptana plug-in as the IDE I use for peach³ development. This one environment has support for everything I need while developing a Django application: Python, HTML and JavaScript support is great, with code completion, including completion for the Ext.js javascript library. And I even have the idea that I’m not using the full power of Eclipse yet. By default, Eclipse and Aptana have no Python support, but it can be integrated with PyDev. The only thing missing to make it the best environment (in my opinion) is support for Django template tags: a Django template tag inside a HTML or JavaScript file usually results in an inline error message. But you can just ignore these error messages. For some of the most used Django management commands (runserver and test) I’ve defined ‘tools’ in the Eclipse interface and I can now start my development server or run the testsuite with a single click inside Eclipse. Here is how I set up the single-click runserver tool: In “Run > External Tools > External Tools…” I’ve added a new tool called “Django Runserver” and I set up the following on … -
ORD Camp a Huge Success
I was luck enough to be invited to attend ORD Camp this last weekend in blisteringly cold Chicago.  ORD Camp is an invite only, FooCamp style unconference targeted at geeks living in the Midwest. Having never attended a FooCamp style event I wasn't sure what to expect.  I can now say if you ever have the opportunity to attend an event like this it is well worth your time. As you can see from the attendee list it was a very diverse group of people, not just the usual crowd of notable Open Source geeks.  The amount of brain power in that room was simply amazing and I can't remember when I had as much fun.  Some sessions were presentations, others were just focused discussions.  Everything from how words work, brewing beer, life hacking, to what not to do as a startup.  While I loved the sessions the most fun was getting into random conversations ( some ended up being NSFW after midnight and many beers ) others were more typical.  Spent some time talking with people about PostgreSQL's advantages over MySQL, alternative business models, how a certain entrepreneur might improve the performance of their servers, etc. It is difficult … -
Running long processes in Django
My original issue was that I had this piece of code in my Django project that was taking way too long to run, sometimes even leading to a load time out. The particular situation happens very infrequently (at most once a week), so it was just a matter of getting the process to run successfully. Along the way, though, I learned a lot about spawning processes, distributed computing, and the different options we have in the Python community. The different approaches are just ways to get the processing to be done outside the Django process, of course. cron and queue cron I will first start with the recommended process of taking care of this issue. You can setup a cron job to run some code that checks every minute to see if there’s anything to process and then run the appropriate code. Cron jobs are pretty simple to setup and pretty effective. All you need to do is edit the crontab with the time intervals you want the service to be run and your code takes care of the rest. django-queue-service The cron part of this solution takes care of when the processing happens, but what handles why it happens? … -
Pinax update: breaks external dependencies
Have you been working off the Pinax trunk only to be surprised by the following message after an update: Error: No module named notification Basically what happened is summarized on the django-hotclub page, which I apparently should start paying closer attention to: http://code.google.com/p/django-hotclub/wiki/MovingToDistutils What this all means is that you will need to change your setup a bit to get Pinax to work in its new setup… What I had to do first was install pip and virtualenv sudo easy_install pip sudo easy_install virtualenv If you need to setup easy_install or you have any trouble with the following step, try updating python-setuptools sudo apt-get install python-setuptools You will also need to install git and bzr as mentioned in the wiki page. On my Ubuntu box, it was simple as installing git-core and bzr sudo apt-get install git-core sudo apt-get install bzr After that you need to run the following command to download the apps (Feb 6, typo fixed, thanks Vernon): sudo pip install -r pinax/requirements/external_apps.txt And then back to your normal: python manage.py syncdb python manage.py runserver (of course this is just on your dev box…) hope that helps. -
The taste of shame and humiliation
What a way to start the morning: Yup, that’s right; my former employer the Lawrence Journal-World – one of the most ground-breaking, award-winning, forward-looking, innovative news organizations in the world – is now serving pop-under ads. I really did think that my former bosses, friends, and colleagues there knew better. I can only hope this was a top-down do-it-or-lose-your-job edict, but even that smacks of the kind of dictatorial micromanagement I thought the company was above. -
Django Site of the Week - Deskography
Seeing how other people work is something that seems to be of interest to most developers. Whether it's because they want to become better workers themselves or because they're somewhat voyeuristic is open to debate - either way, Django-powered website Deskography is a well-designed social desk-sharing website. This week, I spoke to Gustaf Sjöberg of Distrop to find out why they chose Django to power Deskography, and what it's allowed them to do. You can read the interview over at the Django Site of the Week. -
Django Site of the Week - Deskography
Seeing how other people work is something that seems to be of interest to most developers. Whether it's because they want to become better workers themselves or because they're somewhat voyeuristic is open to debate - either way, Django-powered website Deskography is a well-designed social desk-sharing website. This week, I spoke … -
MEDIA_URL and context from processors available in HTTP 500 template
It’s easy to create a custom template for HTTP 500 errors. All you have to do is create a file named 500.html in any of the application’s TEMPLATE_DIRS. But in almost all cases you want to use media in this page. It’s good to have an error page with the same look and feel of [...] -
Better spam defense for Django comments
I've finally found the time to package up an improved version of my comment validation. In addition to the original's simple link count, this version checks if the commenter's IP has been banned or has submitted questionable (non-public) comments in the past, and compares the comment to a series of phrase blacklists. It also includes batch tools in the comments administration pages, to reduce the time you spend banning IPs or deleting spam. -
Enable distutils for a django reusable app
As you might already be aware Pinax move to distutils, this change has been described by James Tauber in this post. Today I have decided to make my feet wet with this approach for a django reusable app. I have been guided by jezdez on #pinax.Before starting I would recommend you to read this page, yes I know, it is a bit long but very interesting. after this reading you will be well prepared to start to work on you django reusable app.I have used one of my project django-geotagging to experiment with this approach. The project can be found on launchpad there. The good news about this approach is that all the major rcs are supported : SVN, BZR, HG, ... If your favorite versionning system is missing there is a good chance that I just forget to mention it. This list is not exhaustive.The core of this approach is a file called setup.py that need to be paced at the root of your repository, most of its argument are self explanatory.This file enable you to setup a complete env in 4 steps :Create a virtual env : virtualenv geotagging_env Move into that env : cd geotagging_env Activate the … -
To FogBugz With Python
A couple of weeks ago, I announced the pyfogbugz project that will, when complete, serve as a python wrapper around the FogBugz API. I have had very little time to spend on it recently so it has not progressed much at all. However, one feature that I have added recently is the ability to use the simple BugzScout interface for submitting bug reports. The one feature about this interface that solves an immediate problem for me is being able to deal with duplicate exception reports. One of my major annoyances with picking up exception reports from an email inbox that FogBugz creates tickets from is that it can't deal with duplicates, so I end up spending a lot of time gardening tickets that are duplicates of each other. BugzScout will solve this problem by automatically appending to a ticket that has an identical title. I find this extremely useful. While the library is not comlete, the BugzScout part of it is usable. To install and use: git clone git://github.com/paltman/pyfogbugz.git cd pyfogbugz pylink pyfogbugz ## See link [1] to Eric Florenzano's post Now in your python script: from pyfogbuz.scout import post_report post_report('title of the report', 'body of the report -- what … -
To FogBugz With Python
A couple of weeks ago, I announced the pyfogbugz project that will, when complete, serve as a python wrapper around the FogBugz API. I have had very little time to spend on it recently so it has not progressed much at all. However, one feature that I have added recently is the ability to use the simple BugzScout interface for submitting bug reports. The one feature about this interface that solves an immediate problem for me is being able to deal with duplicate exception reports. One of my major annoyances with picking up exception reports from an email inbox that FogBugz creates tickets from is that it can't deal with duplicates, so I end up spending a lot of time gardening tickets that are duplicates of each other. BugzScout will solve this problem by automatically appending to a ticket that has an identical title. I find this extremely useful. While the library is not comlete, the BugzScout part of it is usable. To install and use: git clone git://github.com/paltman/pyfogbugz.git cd pyfogbugz pylink pyfogbugz ## See link [1] to Eric Florenzano's post Now in your python script: from pyfogbuz.scout import post_report post_report('title of the report', 'body of the report -- what … -
Django ORM now supports fields references in filters
Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it. Before this update, queryset could be filtered only by absolute values. queryset.filter(field='absolute value') Will generate somthing like this: SELECT * FROM table_name WHERE field = 'absolute value'; Now you [...] -
Full-text searching in Django with PostgreSQL and tsearch2
Recently, I have wanted to improve the searching ability in a number of my projects. I've often added a search box that simply does an icontains filter, which works fine for small sites but doesn't scale due to the inefficiency of matching text with basic SQL queries. The plus side of an icontains filter is that it works on all of Django's database backends (with the exception of SQLite, which works but in a case-sensitive way). All of my projects run on PostgreSQL, an open-source database package that runs beautifully everywhere I've tried it. If you are familiar with MySQL, Postgres shouldn't be a problem for you. When you want to do full-text searching from within your Django projects, you have a few different choices available to you, mostly depending on which database backend you're using: MySQL has built-in fulltext indexing which can be used in Django with some basic ORM extensions. PostgreSQL prior to 8.3 has a 'contrib' module known as tsearch2, which allows full-text indexing within your SQL queries. This is what I am going to detail below. PostgreSQL 8.3 and later has tsearch2 built-in, which is usable in Django if you follow these directions from Barry Pederson … -
Full-text searching in Django with PostgreSQL and tsearch2
Recently, I have wanted to improve the searching ability in a number of my projects. I've often added a search box that simply does an icontains filter, which works fine for small sites but doesn't scale due to the inefficiency of matching text with basic SQL queries. The plus side … -
From WordPress to Django – Part 2
Welcome back. In part 2 I'll be getting to the meat of the issue, which is retrieving the data from an existing Wordpress blog, and feeding the data into my own models. -
Django Site of the Week - ForecastWatch
Eric Floehr is the man behind ForecastWatch and ForecastAdvisor, two Django-powered weather websites that aggregate and analyse weather forecasts to compare their accuracy on an ongoing basis. This week, I spoke to Eric about the history behind his sites, how he handles massive data sets, and his conversion from Ruby on Rails to Django. You can read all about it over at the Django Site of the Week. This weeks' SOTW was delayed by a day due to our Australia Day celebrations on the 26th of January. I figured if they can delay an international Tennis match for fireworks, I could delay this as well :) -
Django Site of the Week - ForecastWatch
Eric Floehr is the man behind ForecastWatch and ForecastAdvisor, two Django-powered weather websites that aggregate and analyse weather forecasts to compare their accuracy on an ongoing basis. This week, I spoke to Eric about the history behind his sites, how he handles massive data sets, and his conversion from Ruby …