Admin class not in admin.py

Predictable project structure and following common patterns simplifies maintenance of a codebase.

Django developers come to expect Admin-related objects to be in admin.py. Failure to do this will result in more time spent looking for where code lives.

If we spot this issue in your GitHub pull request we give this advice:

views.py → admin.pymaintainabilitymedium
from django.contrib import admin
from . import models
	
admin.site.register(models.Author)

Predictable project structure and following common patterns simplifies maintenance of a codebase.

Django developers come to expect Admin-related objects to be in admin.py. Failure to do this will result in more time spent looking for where code lives.

Read more
Protect your pull requests from over 40 types of common Django technical debts with our GitHub code review bot.

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code misplaced-admin-class in your pyproject.toml file.

Read more about configuring Django Doctor.