views:

502

answers:

1

I have a member profiles application that stores simple information about members of a team. Part of the profile is an image to be used as an avatar. I've been using Photologue to create standard galleries of photos, but it has an ImageModel that can be extended to take advantage of Photologue's resizing and caching functionality.

The problem is, the example they give on their page looks like this:

from django.contrib.auth.models import User
from photologue.models import ImageModel

class UserPortrait(ImageModel):
    user = models.OneToOneField(User, primary_key=True)

I could replace User with Member and all would be good, except for the fact that editing the profile becomes a two step process; First I'd have to create a Member profile, then create a UserPortrait and associate it with the Member. I'd like to streamline this back into a single step process, as if I were using an ImageField.

I've overridden image fields at the form level and the admin.py level, but I'm wondering if I can deal with this at the model level or even the field level. I'd like to have the inline functionality of an ImageField but still have the file managed by a separated, related model. Actual model inlines seem like overkill since its just one image.

+1  A: 

Your Member class should extend ImageModel. There is no need for an additional class (e.g. UserPortrait).

zooglash
I suppose the example is how you'd have to do it for Users since the User class can't be extended.
Soviut
I decided to go the inline route since I reasoned that I may want more than one image associated with a profile at some point.
Soviut