[Django]-Django admin list edit

1đź‘Ť

âś…

I didn’t tested this yet, but probably the problem is, that you’ve overridden the default manager.

From the Django docs: Default managers

If you use custom Manager objects, take note that the first Manager Django encounters (in the order in which they’re defined in the model) has a special status. Django interprets the first Manager defined in a class as the “default” Manager, and several parts of Django (including dumpdata) will use that Manager exclusively for that model. As a result, it’s a good idea to be careful in your choice of default manager in order to avoid a situation where overriding get_queryset() results in an inability to retrieve objects you’d like to work with.

So using your “UnrestrictedManager” first and your Custom Manager as second should do the trick.

👤normic

1đź‘Ť

I solved this issue by creating a proxy model with a simple manager.

class UnrestrictedMyModel(MyModel):
    objects = models.Manager()

    class Meta:
        proxy = True

site.register(UnrestrictedMyModel, MyModelAdmin)

But I am still looking for a better solution.

👤Yossi

1đź‘Ť

Check if you have all list_display as list_editable.
You can:

  1. make one of list_editable field to be a non-editable link by adding it to list_display_links
  2. add id into list_display
👤Danil

Leave a comment