Organizational Research By

Surprising Reserch Topic questions - Question:Django custom admin urls not defined

I am trying to add two URLs to a model admin.

class JobTitleAdmin(admin.ModelAdmin):
    inlines = [OccupationTagInline, ]
    model = JobTitle
    search_fields = ['title',]
    list_filter = ['status',]
    actions =['add_to_job_category', 'move_to_job_category' ]

    def add_to_job_category_view(self, request):

        return render_to_response(
                'action': 'add',
                'featured_occupations': Occupation.objects.filter(featured=True),
                'title_ids': array(request.GET['foo'])

    def get_urls(self):
        urls = super(JobTitleAdmin, self).get_urls()
        custom_urls = patterns('',
            url(r'^add_to_job_category/$', self.admin_site.admin_view(self.add_to_job_category_view), name='admin_jobtitle_add_to_cat',),
            url(r'^move_to_job_category/$', self.admin_site.admin_view(self.move_to_job_category_view), name='admin_jobtitle_move_to_cat',)

        return custom_urls + urls

I've omitted the views code for simplicity.

These 2 patterns are not defined as I get a 404 if I am trying to access them and thet're not listed in django debud 404 page. Yet the method get_urls is properly called (twice actually, not sure why).

What could be wrong?

asked Sep 13, 2013 in Java Interview Questions by rajesh
edited Sep 12, 2013
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.