Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does admin.autodiscover actually do?

Tags:

python

django

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?

like image 222
Frozen Flame Avatar asked Dec 26 '13 12:12

Frozen Flame


1 Answers

As u said: autodiscover() load all admin.py from the apps folders. So you have in the /admin/ all the models that you use (from your own app or not).

I recommend to use autodiscover() if you are going to use the admin app.

P.D. additionally some app have their on autodiscover with more functionalities.

like image 190
Viroide Avatar answered Oct 05 '22 11:10

Viroide