Reputation: 135
I am reading Django's official docs, and there is this sentence on reverse_lazy()
:
It is useful for when you need to use a URL reversal before your project’s URLConf is loaded.
Could anybody explain what is meant by "URLConf loading"?
Upvotes: 0
Views: 140
Reputation: 308839
URLconf is short for URL configuration.
Most of the time, your settings has
ROOT_URLCONF = 'myproject.urls'
in which case your URL conf is the urls.py
in the inner project folder.
As the docs sugest, you can’t use reverse
at module level in your settings or urls.py
, because that code is loaded when the server starts before the urls.py
have finished loading. In those cases, you can use reverse_lazy
, which delays reversing the url until later.
Upvotes: 1