[Answer]-Need to add view list anchor tag for another model in django admin

1👍

I assume that your app is called app and question field of the Answer model is named question 🙂

from django.core.urlresolvers import reverse

class QuestionAdmin(admin.ModelAdmin):
    list_display = ['question', 'date', 'view_answers']

    def view_answers(self, obj):
        url = reverse("admin:app_answer_changelist")
        return '<a href="%s?question=%d">View answers</a>' % (url, obj.pk)
    view_answers.short_description = 'View answers'
    view_answers.allow_tags = True

Leave a comment