Reputation: 357
I cloned a sample app for django and run code inspection and found that admin.autodiscover is called before importing the views file, that's used for the patterns later:
from django.contrib import admin
from django.urls import path
admin.autodiscover()
import hello.views
urlpatterns = [
path("", hello.views.index, name="index"),
...
]
This triggers a PEP8 code style warning as the imports are not all on the top of the file. I'm afraid that moving it may have unintended side effects. Is that the case?
Upvotes: 1
Views: 584
Reputation: 886
According to docs you don't need to call the autodiscover
function since django will call in when AdminConfig
loads.
Upvotes: 1