Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django url debugger

I'm developing a django application and over time, the URLs have grown. I have a lot of them with me now and due to some change I made, one view started to malfunction. When I try to GET http://example.com/foo/edit_profile, it's supposed to execute a view certain view function X but it's executing Y instead. Somewhere the url routing is messing up and I can't figure it out. I used the django.core.urlresolvers.resolve method to try it from the shell and I can confirm that the URL is getting wrongly resolved. However, I don't know how to debug this and pinpoint the problem.

Ideally, I'd like to see something like "tested this pattern", "tested this pattern" etc. till it finally finds the correct one and I can then look around where it resolved. I can't find anything like this.

Isn't this a common problem for larger projects? What do people do?

Update

I know how the system works and how to look through the URLs one by one. That's what I'm trying to do. This question is basically asking for a shortcut.

like image 432
Noufal Ibrahim Avatar asked Sep 01 '10 06:09

Noufal Ibrahim


People also ask

How do I add debug toolbar URLs in Django?

Add the URLs ¶ Add django-debug-toolbar’s URLs to your project’s URLconf: This example uses the __debug__ prefix, but you can use any prefix that doesn’t clash with your application’s URLs. Note the lack of quotes around debug_toolbar.urls.

Does the debug toolbar support Django channels or async projects?

The Debug Toolbar currently doesn’t support Django Channels or async projects. If you are using Django channels are having issues getting panels to load, please review the documentation for the configuration option RENDER_PANELS.

How do I add the middleware associated with the Django debug toolbar?

The middleware associated with the Django Debug toolbar has to be added into the MIDDLEWARE section in settings.py The debug toolbar is shown only if the IP is present in the INTERNAL_IPS list in settings.py. For local development purposes, add the IP ‘127.0.0.1’ into the list.

How to create a URL in Django?

How to create a Django url is given below: 1. Creating a url USING PATH () The path method allows to return of an element to be included in URL patterns tuple which will be used as an url pattern. This was introduced in Django version 2.0 along with the re_path () method. 2. Creating a Django URL USING RE_PATH ()


1 Answers

have you already tried to run

manage.py show_urls 

after installing django_extensions?

http://vimeo.com/1720508 - watch from 06:58.

This should give you in what order the url resolution is attempted.

Hope this helps

like image 127
Sergio Morstabilini Avatar answered Sep 20 '22 00:09

Sergio Morstabilini