Changes between Initial Version and Version 1 of Ticket #15602, comment 19
- Timestamp:
- Jul 14, 2018, 12:54:23 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #15602, comment 19
initial v1 20 20 class TransactionTabularInline(admin.TabularInline): 21 21 model = models.Transaction 22 extra = 1 23 max_num = 0 22 extra = 1 # extra must be 1 to make the magic work 23 max_num = 0 # somehow this disable the "add" because max_num > extra 24 24 fields = (contains only a handful of fields) 25 25 can_delete = False 26 show_change_link = True 26 show_change_link = True # allow viewing the full entry in another page 27 27 readonly_fields = [ 28 28 the list of 'fields' … … 36 36 def get_queryset(self, request): 37 37 queryset = super().get_queryset(request) 38 return queryset.none() 38 return queryset.none() # no existing records will appears 39 39 }}} 40 40 … … 42 42 43 43 I think you can use two (stacked) inlines, one for existing records with more `readonly_fields`, and one without readonly but return an empty query_set. 44 45 I found `queryset.none()` from django's code, when users has no permission on the object. So, I suppose this is "okay" when I do not want to display existing records for my own reason.