I have two models with one of them as inline to other. I have made fields of inline model read only.
class FollowUpInLine(admin.TabularInline):
model = md.FollowUp
extra = 0
can_delete = False
def get_readonly_fields(self, request, obj=None):
if request.user.is_superuser == False:
if obj: # editing an existing object
return self.readonly_fields + (
'follow_up_date',
'status_inquiry',
'remarks',
'followup_done_by',
)
return self.readonly_fields
However this does not allows to add new fields when "Add another" is clicked in inline rather it changes them to label with value "None". How can I make fields inline but add when next inline is to added?
I found the answer to this. We need to insert a construct form and then call this form from the inline class as I have done which is shown below: