I'm pretty sure its not necessarily meant to work like this, however
one way it does, the other it doesnt.

I have the following (cut down slightly, but the important stuff is
here)

# image/models.py
class Image(models.Model):
    type = models.ForeignKey('image.Type')
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey
('type__content_type','object_id')


class Type(models.Model):
    slug = models.SlugField()
    content_type = models.ForeignKey(ContentType)

class Size(models.Model):
    type = models.ForeignKey('image.Type')
    width = models.IntegerField()


# clan/models.py
class Clan(models.Model):
    image = generic.GenericRelation(
        Image,
        content_type_field='type__content_type',
        object_id_field='object_id'
    )

For forward lookups using clan.image.all, works fine, however the
reverse image.content_object throws the following error

Image has no field named 'type__content_type'

I don't actually need to use it this way round, however deleting the
clan in this case also deletes the images, this is when that lookup
was called.

The reason for this possibly crazy idea as follows
The image has a type, and the type has multiple sizes
I build the url as follows

/uploads/TYPE_SLUG/SIZE_SLUG/IMAGE_ID.jpg
so maybe /uploads/user/medium/111.jpg

and template tags work in a similar way to as follows
<img src="{{image.large.src}} " width="{{image.large.width}}"
height="{{image.large.height}}" />


I have a feeling I am going to need to re-write this lot anyway - far
too many lookups, but some input would be appreciated.

Matt.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to