Source

django-ajax-poll / poll / admin.py

Full commit
from gpoll.poll.models import *
from django.contrib import admin 
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _            

class polladmin(admin.ModelAdmin):
	actions = ['delete_selected']
	list_filter = ['publish']
	list_display = ['question', 'list_answers', 'publish', 'publish_date', 'download_answers']
	
	fieldsets = (
		('Content', {
			'fields': ( 'question', 'answers', 'publish', 'publish_date')
		}),
		
	)
	
	
	def list_answers(self, obj):
		answers = obj.answers.splitlines(True)
		a_list = ""
		for a in answers:
			a_list += '%s<br />' % a.strip()
		return a_list
	list_answers.short_description = 'Answers' 
	list_answers.allow_tags = True
	
	def download_answers(self, obj):
		
		return '<a href="%s">%s</a>' % (reverse('poll_export_answers',kwargs={'object_id':obj.id}), 'Download CSV')
	download_answers.short_description = 'Data dump' 
	download_answers.allow_tags = True
admin.site.register(poll, polladmin) 

class pollsubmissionadmin(admin.ModelAdmin):
	list_filter = ['poll_ref']
	list_display = ['poll_ref', 'answer_id', 'answer_text', 'submit_date']
	actions = ['delete_selected']
	
	

admin.site.register(poll_submission, pollsubmissionadmin)