#30666: Use autocomplete_fields with models not registered in the admin
-----------------------------------------------+------------------------
Reporter: Germano Gabbianelli | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------------+------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/30666>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.a6fad7f03a1af70494ea7d103503d368%40djangoproject.com.