Refactoring of admin.py