What does admin.autodiscover actually do?

Viewed 8559

I've long been curious about what

admin.autodiscover()

actually do. The document didn't say much about it:

Above we used admin.autodiscover() to automatically load the INSTALLED_APPS admin.py modules.

and

There is really no need to use autodiscover when using your own AdminSite instance since you will likely be importing all the per-app admin.py modules in your myproject.admin module.

If I don't uncommnet

# admin.autodiscover()

what functionality I will lose?

And for what consideration should I use or not use autodiscover?

2 Answers

admin.py is executed whenever your django loads URLconf from urls.py, the autodiscover() will search for all the apps in INSTALLED_APPS one by one and executes the code in that file.

Related