@@ -0,0 +1,1928 @@
+from django.contrib import admin%0Afrom django.core.urlresolvers import reverse%0A%0Afrom polls.models import Question, Choice%0A%0A%0Aclass ParentListFilter(admin.SimpleListFilter):%0A    title = 'parent'%0A    parameter_name = 'parent'%0A%0A    def lookups(self, request, model_admin):%0A        %22%22%22%0A        Returns a list of tuples. The first element in each%0A        tuple is the coded value for the option that will%0A        appear in the URL query. The second element is the%0A        human-readable name for the option that will appear%0A        in the right sidebar.%0A        %22%22%22%0A        return %5B(q.slug, q.title) for q in Question.objects.all()%5D%0A%0A    def queryset(self, request, queryset):%0A        %22%22%22%0A        Returns the filtered queryset based on the value%0A        provided in the query string and retrievable via%0A        %60self.value()%60.%0A        %22%22%22%0A        if self.value():%0A            parent = Question.objects.get(slug=self.value())%0A            return Choice.objects.child_of(parent).order_by('-id')%0A        return queryset%0A%0A%0Aclass QuestionAdmin(admin.ModelAdmin):%0A    list_display = ('entries', 'live')%0A    fieldsets = (%0A        (%0A            None,%0A            %7B'fields': ('title', )%7D%0A        ),%0A    )%0A    readonly_fields = %5B'title'%5D%0A%0A    def entries(self, obj, *args, **kwargs):%0A        url = reverse('admin:polls_choice_changelist')%0A        return '%3Ca href=%22%25s?parent=%25s%22%3E%25s%3C/a%3E' %25 (%0A            url, obj.slug, obj)%0A%0A    entries.allow_tags = True%0A    entries.short_description = 'Title'%0A%0A%0Aclass ChoiceAdmin(admin.ModelAdmin):%0A    list_display = ('title', 'votes', 'live', '_parent')%0A    list_filter = (ParentListFilter, )%0A    fieldsets = (%0A        (%0A            None,%0A            %7B'fields': ('title', 'votes')%7D%0A        ),%0A    )%0A    readonly_fields = %5B'title', 'votes'%5D%0A%0A    def _parent(self, obj, *args, **kwargs):%0A        return obj.get_parent().title%0A%0Aadmin.site.register(Question, QuestionAdmin)%0Aadmin.site.register(Choice, ChoiceAdmin)%0A

add polls view to django admin