How to get a namespaced view name from a URL (path_info) in Django

In Django, you want a view name with a namespace from the URL path (for example, / admin / auth / user / 1 / change /).

It also displays the parsed arguments.

from django.core.urlresolvers import get_resolver

path_info = '/admin/auth/user/1/change/'

resolver = get_resolver(None)  #Modern Django doesn't have to have arguments

resolver_match = resolver.resolve(path_info)
print('view_name:', resolver_match.view_name)

callback, callback_args, callback_kwargs = resolver_match
print('args:', callback_args, ', kwargs:', callback_kwargs)

result

view_name: admin:auth_user_change
args: ('1',) , kwargs: {}

Recommended Posts

How to get a namespaced view name from a URL (path_info) in Django
How to get a stacktrace in python
How to get results from id in Celery
How to get a value from a parameter store in lambda (using python)
How to create a Rest Api in Django
How to get the variable name itself in python
How to get multiple model objects randomly in Django
How to use bootstrap in Django generic class view
How to upload files in Django generic class view
How to reference static files in a Django project
How to slice a block multiple array from a multiple array in Python
I tried "How to get a method decorated in Python"
How to generate a query using the IN operator in Django
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
How to get a list of links from a page from wikipedia
How to get a quadratic array of squares in a spiral!
How to reflect CSS in Django
How to get all the possible values in a regular expression
[Python] How to get & change rows / columns / values from a table.
Here's a brief summary of how to get started with Django
How to use Visual Recognition to get LINE ID from a girl
How to get the vertex coordinates of a feature in ArcPy
How to deploy a Django app on heroku in just 5 minutes
How to get a job as an engineer from your 30s
How to create a clone from Github
Qiita (1) How to write a code name
How to delete expired sessions in Django
How to create a repository from media
How to do Server-Sent Events in Django
How to implement Scroll View in pythonista 1
How to convert DateTimeField format in Django
How to view images in Django's Admin
If you get a Programming Error: (1146, "Table'<table name>' doesn't exist") in Django
How to make a container name a subdomain and make it accessible in Docker
How to get a sample report from a hash value using VirusTotal's API
How to get people to try out django rest framework features in one file
How to open a web browser from python
How to clear tuples in a list (Python)
How to implement Rails helper-like functionality in Django
How to create a function object from a string
How to uniquely identify the source of access in the Django Generic Class View
How to get the "name" of a field whose value is limited by the choice attribute in Django's model
How to get the notebook name you are currently using in Google Colab
How to develop a cart app with Django
How to create a JSON file in Python
DJango Memo: From the beginning (creating a view)
How to reflect ImageField in Django + Docker (pillow)
How to count the number of elements in Django and output to a template
How to run some script regularly in Django
[Django] How to get data by specifying SQL.
How to get help in an interactive shell
How to generate a Python object from JSON
How to implement a gradient picker in Houdini
Get a panoramic image in Google Street View
How to extract coefficients from a fractional formula
How to notify a Discord channel in Python
Pass login user information to view in Django
How to get the files in the [Python] folder
Specify the view URL in your Django template
[Python] What to check when you get a Unicode Decode Error in Django