Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#24931 closed Bug (fixed)

404 error for "Views by namespace admin" at Admin Docs

Reported by: Girish Owned by: Markus Holtermann
Component: Core (URLs) Version: dev
Severity: Normal Keywords: Admin, AdminDocs, urlresolver
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Girish)

I am currently running the master version of the django github project (on 5th Jun 2015 10:46 am).

I followed the instructions (https://docs.djangoproject.com/en/dev/ref/contrib/admin/admindocs/)
to install the admin docs to my django application. Don't forget to install docutils using pip.

If you go the following url (Admin doc):
http://127.0.0.1:8000/admin/doc/

and choose Views and you should get to http://127.0.0.1:8000/admin/doc/views/

there you should find two section

  1. Views by empty namespace
  2. Views by namespace admin

the links to Views by empty namespace works fine but Views by namespace admin leads to
404 error.

https://dl.dropboxusercontent.com/u/53911954/djangobugs/er1.png

https://dl.dropboxusercontent.com/u/53911954/djangobugs/er2.png

Change History (13)

comment:1 by Girish, 9 years ago

Description: modified (diff)
Type: UncategorizedBug

comment:2 by Girish, 9 years ago

Description: modified (diff)

comment:3 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Rigel Di Scala, 9 years ago

Owner: changed from nobody to Rigel Di Scala
Status: newassigned

I'll take a look at it.

comment:5 by Rigel Di Scala, 9 years ago

I am able to reproduce this in 1.9.dev20150607202342.

comment:6 by Rigel Di Scala, 9 years ago

I believe the problem might be due to the fact that those views are actually methods of django.contrib.admin.sites.AdminSite.

comment:7 by Ben McNelly, 9 years ago

Owner: changed from Rigel Di Scala to Ben McNelly

comment:8 by lordscales91, 9 years ago

I think I've spotted where the issue comes from. When you use namespaced urls on your ROOT_URL_CONF you will have RegexURLResolver instances in your patterns, but the _callback_strs are not properly added, maybe it's better to show you a snippet from the actual code on django.core.urlresolvers at version 1.8.4 (I added the comment at the end)

            if isinstance(pattern, RegexURLResolver):
                if pattern.namespace:
                    namespaces[pattern.namespace] = (p_pattern, pattern)
                    if pattern.app_name:
                        apps.setdefault(pattern.app_name, []).append(pattern.namespace)
                else:
                    parent_pat = pattern.regex.pattern
                    for name in pattern.reverse_dict:
                        for matches, pat, defaults in pattern.reverse_dict.getlist(name):
                            new_matches = normalize(parent_pat + pat)
                            lookups.appendlist(
                                name,
                                (
                                    new_matches,
                                    p_pattern + pat,
                                    dict(defaults, **pattern.default_kwargs),
                                )
                            )
                    for namespace, (prefix, sub_pattern) in pattern.namespace_dict.items():
                        namespaces[namespace] = (p_pattern + prefix, sub_pattern)
                    for app_name, namespace_list in pattern.app_dict.items():
                        apps.setdefault(app_name, []).extend(namespace_list)
                    self._callback_strs.update(pattern._callback_strs) # This should be done even if a namespace is specified I think

comment:9 by Markus Holtermann, 8 years ago

Component: contrib.admindocsCore (URLs)
Has patch: set
Keywords: urlresolver added
Owner: changed from Ben McNelly to Markus Holtermann

comment:11 by Markus Holtermann, 8 years ago

This is a regression from #23601

comment:12 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 625b8e92:

Fixed #24931 -- Made namespaced RegexURLResolvers populate callback strings.

Fixed a regression in 2f16ff5a6cbd71fc6c50e88e4087f3657222e90e.

Thanks Tim Graham for the review.

comment:13 by Tim Graham <timograham@…>, 8 years ago

In 31a789f:

[1.10.x] Fixed #24931 -- Made namespaced RegexURLResolvers populate callback strings.

Fixed a regression in 2f16ff5a6cbd71fc6c50e88e4087f3657222e90e.

Thanks Tim Graham for the review.

Backport of 625b8e9295d79650208bfb3fca8bf9e6aaf578e4 from master

Note: See TracTickets for help on using tickets.
Back to Top