Proxy model edit/add missing on Foreign Key fields?

33 Views Asked by At

Goal: I want to group some of my models inside of other apps on the Admin page.

How: I created a proxy model for each of my models and defined app_label to be that of the app I want.

class MyModelProxy(MyModel):
    class Meta:
        proxy = True
        app_label = 'auth' # specify a different app for the model to be grouped with
        verbose_name = MyModel._meta.verbose_name
        verbose_name_plural = MyModel._meta.verbose_name_plural

I registered the proxy model together with the custom admin model I created for each.

admin.site.register(MyModelProxy, MyModelAdmin)

Issue 1: My Foreign Key fields lose the icons to edit/add another object in the view/change pages. If I register the original model with the admin model, it displays fine.

Without proxy model (original)--> (proxy) With proxy model

Issue 2: If I set autocomplete_fields inside the corresponding admin models, I get an error that the original model should be registered. But I want to only register the proxy model, not both ?

0

There are 0 best solutions below