views:

77

answers:

1

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?

A: 

How about making the UserProfile read only? http://stackoverflow.com/questions/339969/django-foreign-keys-read-only

There are other ideas in this post also.

Close to what I want to do but not quite (I think). I want to display all the fields from the UserProfile on the Order page, so it's easy to see the user's name, address etc when looking at an order, rather than just their username
Oli