[Answered ]-Ignore inline model when saving

2πŸ‘

βœ…

From your response on my comment I am getting the idea you want to show some extra information in the admin, that is not editable. This can be achieved using readonly_fields in the Inline, for completeness you should also set the max_num to 0, because otherwise you can add empty inlines.

You could enter all fields manually or use something like given in this answer: https://stackoverflow.com/a/42877484/2354734

The end result would look something like this.

class UserOrdersAdmin(admin.TabularInline):
    model = Order
    classes = ['collapse']
    max_num = 0

    def get_readonly_fields(self, request, obj=None):
        return list(set(
            [field.name for field in self.opts.local_fields] +
            [field.name for field in self.opts.local_many_to_many]
        ))

For completeness of the answer also a link to the documentation

πŸ‘€jgadelange

0πŸ‘

Try this:

class UserOrdersAdmin(admin.TabularInline):
    model = Order
    classes = ['collapse']
    extra = 0
πŸ‘€Diego Puente

Leave a comment