Opened 5 years ago

Closed 5 years ago

#30666 closed New feature (wontfix)

Use autocomplete_fields with models not registered in the admin

Reported by: Germano Gabbianelli Owned by: nobody
Component: contrib.admin Version: 2.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I think we should add the possibility to use autocomplete_fields with models not registered in the admin.

For a simple use case consider that I might be attempting to customize the default UserAdmin, by replacing all the filter_horizontal fields with autocomplete_fields:

from django.contrib.auth.admin import admin, User, UserAdmin

admin.site.unregister(User)

@admin.register(User)
class UserAdmin(UserAdmin):
    filter_horizontal = ()
    autocomplete_fields = ("groups", "user_permissions")

This works for groups, because by default Group is registered in the admin, but won't work for user_permissions giving the following error:

<class 'djfoo.admin.UserAdmin'>: (admin.E039) An admin for model "Permission" has to be registered to be referenced by UserAdmin.autocomplete_fields.

In this specific case I don't want to register Permission with the admin, but I think I should be able to use different UI widgets for ManyToMany fields interchangeably.

Change History (1)

comment:1 by Carlton Gibson, 5 years ago

Resolution: wontfix
Status: newclosed

This would require a major restructuring of the way autocomplete_fields functions. Maybe that's feasible but it would need a concrete proposal — exactly how is that going to work? — and agreement based on that via the DevelopersMailingList before I think we can take it on.

Note: See TracTickets for help on using tickets.
Back to Top