Hello. My name is Noemi Millman, and Triopter is my web development agency. We handcraft beautiful, dynamic websites.

See what I can do for you.

Noemi Millman: Triopter: Category Archives for "django"

Django 1.0: Filtering object list and ForeignKey (ModelChoiceField) in Admin Site (contrib.admin)

PLEASE NOTE: The following explanation refers to Django v1.0 and is no longer fully applicable. Since DJango 1.1 or so, the request object is passed to ModelAdmin.formfield_for_dbfield and the new ModelAdmin.formfield_for_foreignkey by default, which makes this much simpler to accomplish.

I’m currently building a custom multi-blogging application in Django, and one of the challenges I ran into when developing the admin section was how to restrict users to seeing and editing only their own data.

Imagine the following (simplified) models:

class Blog(models.Model):
  owner = models.OneToOneField(User, primary_key=True)
  title = models.CharField(max_length=32)

class Entry(models.Model):
  blog = models.ForeignKey(Blog)
  slug = models.SlugField(max_length=255, db_index=True)
  headline = models.CharField(max_length=255)
  content = models.TextField()

If I want to show the …

Upgrading Django from Stable to Subversion

Django is in fairly heavy development, heading for a 1.0 release, and not only does there seem to be a lot of new functionality in the newest versions, but some of the older functionality is expected to break.

Since word on the mailing list is that development versions are not only quite stable, but actually recommended over the stable version, and since I don’t have any deployed apps to worry about breaking, I thought it would be better to upgrade now than later.

Even better, this will make future upgrades as simple as a single subversion command (and, well, some fixes for …

Adventures in Django – Comments and more

I was home sick from work today, so once I felt well enough to crawl out of bed and sit in front of the computer, I decided to catch up a bit more on my Django.
Quick-n-Easy Comments
First thing I did was to replace the commenting system I’d created for my blog-app-in-progress with the commenting framework that comes for “free” with Django.  It’s not as fully featured as I might like, but it’s got some pretty nifty options, and is fairly easy to set up.  I figured I’d rather know how to use this than re-implement comments any time I …