How to do reverse URL search in Django namespaced reusable application

后端 未结 3 1313
不思量自难忘°
不思量自难忘° 2021-01-31 17:37

Consider that I include namespaced reusable application:

urlpatterns = patterns(\'\',
    # ella urls
    url(\'^ella/\', include(\'ella.core.urls\', namespace=\         


        
3条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 18:30

    At least in Django 1.8 you can write something like this:

    url = reverse('%s:object_detail' % request.resolver_match.namespace, kwargs={'required' : 'params'})

    request.resolver_match.namespace is a string containing the namespace of the currently running view.

提交回复
热议问题