Extensions to `@admin.register` fixer
See original GitHub issueDescription
Following #182 / #189 , there are a few more cases that could be covered with further work.
- Support kwarg form ✅ #192
+@admin.register(MyModel)
class MyModelAdmin(...):
...
-admin.site.register(MyModel, admin_class=MyModelAdmin)
- Support multiple models ✅ #200
+@admin.register(Model1, Model2)
class MyModelAdmin(...):
...
-admin.site.register(Model1, MyModelAdmin)
-admin.site.register(Model2, MyModelAdmin)
+@admin.register(Model1, Model2)
class MyModelAdmin(...):
...
-admin.site.register((Model1, Model2), MyModelAdmin)
- Support when there are other class decorators, insert at top ✅ #193
+@admin.register(MyModel)
@something
class MyModelAdmin(...):
...
-admin.site.register(MyModel, MyModelAdmin)
- Support custom admin sites ✅ #228
from myapp.admin import custom_site
+@admin.register(MyModel, site=custom_site)
class MyModelAdmin(...):
...
-custom_site.register(MyModel, MyModelAdmin)
- detect custom site objects heuristically, to avoid affecting other code that uses a ‘register’ pattern, perhaps when the object’s name ends in ‘site’, and the registered class name ends in ‘Admin’ (and maybe the file looks like an admin file, called “admin.py” or in an “admin” directory?)
- Also work for
from django.contrib.gis import admin
- ✅ #204 This imports theregister
decorator for convenience when authoring GIS apps.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Admin & Management - Chrome Web Store
Discover great apps, games, extensions and themes for Google Chrome.
Read more >Cannot Enable or Disable Microsoft Edge Extensions [Tutorial]
Your Admin Has Blocked Extension - Cannot Enable or Disable Microsoft Edge Extensions [Tutorial]If you are unable to enable or disable Edge ...
Read more >Works! Fix Chrome (or Edge) is Managed by your ...
How to fix Chrome or Edge is Managed by your Organization in 3 easy steps. ... It can also randomly disable or prevent...
Read more >Google Chrome → Chrome Extension Blocked By Admin? Try ...
Go to https://chrome.google.com/ and find the extension you want to use. In this case we will be use uBlocker as an example.
Read more >Alternative extension installation methods - Chrome Developers
How to install Chrome Extensions via preferences JSON or Windows registry.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Alright we’ve checked everything off from this list! 🥳
This is now a really awesome feature that covers many cases. Great work @UnknownPlatypus .
@adamchainz Absolutely, would be nice to work on that and I think I have some ideas on how to tackle them.