Inlines in Django Admin
- by Oli
I have two models, Order and UserProfile. Each Order has a ForeignKey to UserProfile, to associate it with that user.
On the django admin page for each Order, I'd like to display the UserProfile associated with it, for easy processing of information.
I have tried inlines:
class UserInline(admin.TabularInline):
model = UserProfile
class ValuationRequestAdmin(admin.ModelAdmin):
list_display = ('address1', 'address2', 'town', 'date_added')
list_filter = ('town', 'date_added')
ordering = ('-date_updated',)
inlines = [
UserInline,
]
But it complains that UserProfile "has no ForeignKey to" Order - which it doesn't, it's the other way around.
Is there a way to do what I want?