How exactly to use `current_app` and `urlconf` arguments of the `reverse()` function in Django

Viewed 147

I had to use the reverse() function in my project and i saw usage of the reverse() in other projects, but i have never used current_app and urlconf arguments.

As i read in docs:

The current_app argument allows you to provide a hint to the resolver indicating the application to which the currently executing view belongs. This current_app argument is used as a hint to resolve application namespaces into URLs on specific application instances, according to the namespaced URL resolution strategy.

The urlconf argument is the URLconf module containing the URL patterns to use for reversing. By default, the root URLconf for the current thread is used.

and the next one:

reverse('polls:index', current_app=self.request.resolver_match.namespace)

And if in above code from the docs self.request.resolver_match.namespace results to author-polls instance namespace why could not i just use reverse() without any current_app argument like this:

reverse('author-polls:index') #no any current_app argument?

Could you give me some tips or maybe a little usage example, please, to understand how, why and when should i use them properly?

0 Answers
Related