I am having trouble with learning to use httpresponseredirect and
reverse.
I am trying to generate an admin action on a selection of a list of
items. The purpose is to generate an intermediate window that can be
used to select a new
status for all the objects,
The admin action shows up in the pulldown menu on /admin/items/item.
However, once clicked, I get the following error: NoReverseMatch at /
admin/items/item/
Any advice would be greatly appreciated, I have been pounding me head
for a day or so on this. I am certainly a novice, so this is likely
to be a very newbie misunderstanding.
Many thanks,
Guy
#myproject/app/admin.py
class ItemAdmin(admin.ModelAdmin):
fieldsets = ( #... )
#set up management command
def change_status(self, request, queryset):
"""call intermediary window to present admin with option to
update
the status for a batch of items. Basically it seems
inefficient to
make several 'admin actions' on the regular item list page,
(one
for each status type). Seems more logical to select change
status from
the admin action dropdown, and then have an intermediate
window ask
what the status should be"""
return HttpResponseRedirect(reverse("change-item-status",
kwargs = {'queryset': queryset, 'request': request,}))
change_status.short_description = "change status of items in
batch"
actions = ['change_status']
#myproject/urls.py
from django.conf import settings
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/items/item/changestatus/$',
'myapp.items.admin_views.changeitemstatus', kwargs = {},
name="change-item-status")
)
#myproject/app/admin_views.py
def changeitemstatus(request,**kwargs):
"""intermediary window to present admin with option to update the
status
and apply any notes to a batch of items"""
template_name='admin/items/changeitemstatus.html'
context = RequestContext(request,
{'items': kwargs['queryset'],
'choices': item.status_choices})
return render(template_name, context)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.