Pass ``/admin/app/model/ID/...`` URLs to the correct admin backend.
Using the ID field, the correct ``ct_id`` parameter can already be determined.fix_request_path_info
parent
e0446bd76c
commit
a8d27ca94e
|
|
@ -5,6 +5,8 @@ Version 0.5.3 (2013-09-17)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
* Fix TypeError when ``base_form`` was not defined.
|
* Fix TypeError when ``base_form`` was not defined.
|
||||||
|
* Fix passing ``/admin/app/model/id/XYZ`` urls to the correct admin backend.
|
||||||
|
There is no need to include a ``?ct_id=..`` field, as the ID already provides enough information.
|
||||||
|
|
||||||
|
|
||||||
Version 0.5.2 (2013-09-05)
|
Version 0.5.2 (2013-09-05)
|
||||||
|
|
|
||||||
|
|
@ -276,11 +276,19 @@ class PolymorphicParentModelAdmin(admin.ModelAdmin):
|
||||||
"""
|
"""
|
||||||
ct_id = int(request.GET.get('ct_id', 0))
|
ct_id = int(request.GET.get('ct_id', 0))
|
||||||
if not ct_id:
|
if not ct_id:
|
||||||
|
# See if the path started with an ID.
|
||||||
|
try:
|
||||||
|
pos = path.find('/')
|
||||||
|
object_id = long(path[0:pos])
|
||||||
|
except ValueError:
|
||||||
raise Http404("No ct_id parameter, unable to find admin subclass for path '{0}'.".format(path))
|
raise Http404("No ct_id parameter, unable to find admin subclass for path '{0}'.".format(path))
|
||||||
|
|
||||||
|
ct_id = self.model.objects.values_list('polymorphic_ctype_id', flat=True).get(pk=object_id)
|
||||||
|
|
||||||
|
|
||||||
real_admin = self._get_real_admin_by_ct(ct_id)
|
real_admin = self._get_real_admin_by_ct(ct_id)
|
||||||
resolver = RegexURLResolver('^', real_admin.urls)
|
resolver = RegexURLResolver('^', real_admin.urls)
|
||||||
resolvermatch = resolver.resolve(path)
|
resolvermatch = resolver.resolve(path) # May raise Resolver404
|
||||||
if not resolvermatch:
|
if not resolvermatch:
|
||||||
raise Http404("No match for path '{0}' in admin subclass.".format(path))
|
raise Http404("No match for path '{0}' in admin subclass.".format(path))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue