Monday, July 5, 2010

Using related models as list-filters in admin

I'm using Photologue 3 (/w Image Kit) and am trying to use a related
model as a list-filter in modeladmin.

Basically Gallery has a m2m relation to Photo, in the Photo modeladmin
I want to be able to sort the images by their related galleries....

I'm totally stuck.

Example from modals.py

class Gallery(models.Model):
photos = models.ManyToManyField('Photo', related_name='galleries',
verbose_name=_('photos'), null=True, blank=True

class Photo(ImageModel):
image = models.ImageField(_('image'), upload_to='photologue')

Example from admin.py

class PhotoAdmin(admin.ModelAdmin):
list_filter = ['date_added', 'tags', '????????????' ]

admin.site.register(Photo, PhotoAdmin)

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate