djangotesting

Django URL-Patterns: How to check if all url-names are distinct?


I want to check if all names of the url patterns in my django project are distinct.

I don't want accidentally use one name twice.


Solution

  • Install django-extensions and run this command:

    python manage.py show_urls
    

    it will show you all urls in your app

    To count names occurrences:

    python manage.py show_urls -f verbose|grep 'URL Name' | sort | uniq -c 
    

    https://github.com/django-extensions/django-extensions