Without putting admin.autodiscover()
in urls.py the admin page shows You don\'t have permission to edit anything
(See SO thread).
Why is this
Before Django 1.7, the recommendation was to put the admin.autodiscover()
call in urls.py. That allowed it to be disabled if necessary. Requiring admin.autodiscover()
instead of calling it automatically was an example of the Python philosophy 'Explicit is better than implicit' in action. Remember, the django.contrib.admin
app is optional, it is not installed on every site, so it wouldn't make sense to always run autodiscover.
Most of the time autodiscover works well enough. However if you require more control, you can manually import specific apps' admin files instead. For example, you might want to register multiple admin sites with different apps in each.
App loading was refactored in Django 1.7. The autodiscover()
was moved to the admin app's default app config. That means that autodiscover now runs when the admin app is loaded, and there's no need to add admin.autodiscover()
to your urls.py. If you do not want autodiscovery, you can now disable it by using the SimpleAdminConfig instead.