Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango will this view shown in the admin index
    primarykey
    data
    text
    <p>Will this view shown as a link in admin index in a portion called modules? Which user can click on the link like normal admin class to view the view?</p> <p>I have a class in called ListAdmin in Admin.py:</p> <pre><code>class ListAdmin(admin.ModelAdmin): def list_view(self, request): return question_list(request) def get_urls(self): urls = super(ListAdmin, self).get_urls() list_urls = patterns('', r'^list/$', self.list_view()) return list_urls + urls </code></pre> <p>The view is in view.py</p> <pre><code>def question_list(request): #questions = Question.objects.filter(topic__icontains = 1) questions = Question.objects.all() return render_to_response('admin/question_list.html', {'questions':questions}) question_list = staff_member_required(question_list) </code></pre> <p>The problem is I don't know how to register the ListAdmin into the admin, because it does not have a list model, and the Question model is already registered.</p> <pre><code>admin.site.register(???, ListAdmin) </code></pre> <p>The possible solution is this:</p> <p><a href="https://stackoverflow.com/questions/2223375/multiplue-modeladmins-views-for-same-model-in-django-admin">Multiple ModelAdmins/views for same model in Django admin</a></p> <p>I added this into my admin.py, it succesfully added a link into the admin index:</p> <pre><code>class List(Question): class Meta: proxy = True class ListAdmin(QuestionAdmin): def list_view(self, request): return question_list(request) admin.site.register(List, ListAdmin) </code></pre> <p>I still think that it is wrong because if I take the line below out from the url.py, it will direct to the Question model:</p> <pre><code>url(r'^admin/modules/list/$', 'exam.admin.modules.views.question_list'), </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload