Mercurial > public > sg101
annotate user_photos/admin.py @ 715:820e57e621e8
Use |safe filter on Haystack templates to get better results w/quotes.
Content was getting escaped, so text with quotes around it was seemingly
missing from the search index. This change fixed that. I verified that the
search results will not leak raw HTML to the page so this should be safe to do.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 17 Sep 2013 20:26:49 -0500 |
parents | d7a0aaabc06c |
children | cc8de231df5a |
rev | line source |
---|---|
bgneal@695 | 1 """Admin definitions for the user_photos application.""" |
bgneal@695 | 2 from django.contrib import admin |
bgneal@695 | 3 |
bgneal@695 | 4 from user_photos.models import Photo |
bgneal@695 | 5 |
bgneal@703 | 6 IMG_TAG = '<img src="%s" alt="thumbnail" />' |
bgneal@695 | 7 |
bgneal@695 | 8 class PhotoAdmin(admin.ModelAdmin): |
bgneal@695 | 9 date_hierarchy = 'upload_date' |
bgneal@695 | 10 ordering = ['-upload_date'] |
bgneal@695 | 11 raw_id_fields = ['user'] |
bgneal@695 | 12 search_fields = ['user__username', 'user__email'] |
bgneal@703 | 13 list_display = ['__unicode__', 'thumbnail'] |
bgneal@703 | 14 |
bgneal@703 | 15 def thumbnail(self, obj): |
bgneal@703 | 16 return IMG_TAG % obj.thumb_url |
bgneal@703 | 17 thumbnail.allow_tags = True |
bgneal@695 | 18 |
bgneal@695 | 19 admin.site.register(Photo, PhotoAdmin) |