Inlines in Django Admin

Posted by Oli on Stack Overflow See other posts from Stack Overflow or by Oli
Published on 2010-05-24T16:35:29Z Indexed on 2010/05/24 20:01 UTC
Read the original article Hit count: 254

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about python

Related posts about django