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
- [Answered ]-Django and formsets
- [Answered ]-Django β TDD: 'HttpRequest' has no attribute 'POST'
- [Answered ]-Django JSONField
- [Answered ]-How i can upload an image with CreateView on my post?
- [Answered ]-Django model unit test
Source:stackexchange.com