Source

django-ajax-poll / poll / admin.py

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) 

   
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.