We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
from django.contrib import admin from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter from .models import Device, DeviceSubscribedEmail, Hub, Plug, PlugMini class DeviceChildAdmin(PolymorphicChildModelAdmin): show_in_index = False def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False @admin.register(Plug) class PlugAdmin(DeviceChildAdmin): base_model = Plug class EmailSubscribersInline(admin.StackedInline): model = DeviceSubscribedEmail extra = 1 @admin.register(PlugMini) class PlugMiniAdmin(DeviceChildAdmin): base_model = PlugMini fieldsets = [ ("info", {"fields": ["id", "name", "country", "hub_device", "is_powered_on"]}), ( "usage", {"fields": ["electricity_of_day", "voltage", "weight", "electric_current"]}, ), ("thresholds", {"fields": ["weight_threshold"]}), ] inlines = [EmailSubscribersInline] @admin.register(Hub) class HubAdmin(DeviceChildAdmin): pass @admin.register(Device) class DeviceAdmin(PolymorphicParentModelAdmin): base_model = Device child_models = [PlugMini, Plug, Hub] list_filter = [PolymorphicChildModelFilter] def has_add_permission(self, request): return False
All models inherit from Device model which is a PolymorphicModel and still, all models show up in the admin page.
Device
PolymorphicModel
The text was updated successfully, but these errors were encountered:
Looks like duplicate of #497 See also workaround #497 (comment)
Sorry, something went wrong.
No branches or pull requests
All models inherit from
Device
model which is aPolymorphicModel
and still, all models show up in the admin page.The text was updated successfully, but these errors were encountered: