Opened 9 years ago

Closed 7 years ago

Last modified 7 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 Changed 9 years ago by Girish

Description: modified (diff)
Type: UncategorizedBug

comment:2 Changed 9 years ago by Girish

Description: modified (diff)

comment:3 Changed 9 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 9 years ago by Rigel Di Scala

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

I'll take a look at it.

comment:5 Changed 9 years ago by Rigel Di Scala

I am able to reproduce this in 1.9.dev20150607202342.

comment:6 Changed 9 years ago by Rigel Di Scala

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

comment:7 Changed 8 years ago by Ben McNelly

Owner: changed from Rigel Di Scala to Ben McNelly

comment:8 Changed 8 years ago by lordscales91

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 Changed 7 years ago by Markus Holtermann

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

comment:11 Changed 7 years ago by Markus Holtermann

This is a regression from #23601

comment:12 Changed 7 years ago by Tim Graham <timograham@…>

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 Changed 7 years ago by Tim Graham <timograham@…>

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