Reputation: 3897
Consider this:
@admin.register(MyModel)
MyModelAdmin(admin.ModelAdmin):
fieldsets = [
('Field1', {'fields': ['field1']}),
('Field2', {'fields': ['field2']}),
...
]
list_display = ('field1', 'field2')
Let's say I have another model for my admin:
@admin.register(AnotherModel)
AnotherModelAdmin(admin.ModelAdmin):
fieldsets = [
('Field1', {'fields': ['field3']}),
('Field2', {'fields': ['field4']}),
...
]
list_display = ('field3', 'field4')
So, I need to show field3
from AnotherModelAdmin
into MyModelAdmin
inlines.
How can I achieve this?
Upvotes: 0
Views: 1364
Reputation: 18092
What about something like that?
class AddressAdmin(admin.ModelAdmin):
fieldsets = [("User", {'fields': ['user_address']}),]
readonly_fields = ['user_address']
def user_address(self, obj):
return obj.user.address
user_address.short_description = 'User address'
Or maybe you are want to actually change the content of the another model field. In that case you can use something like that: How to create a UserProfile form in Django with first_name, last_name modifications?
Upvotes: 2