On 27 Feb, 01:56, Jamie Richard Wilson <utkja...@gmail.com> wrote: > I've extended the User model with a UserPofile model and have inline > editing working. Setup is something like this: > > class UserProfile(models.Model): > user = models.ForeignKey( > User, > unique=True, > ) > position = models.ForeignKey(Position) > ...etc... > > I need alist_displayin admin.py to display 'username', 'first_name', > 'last_name', and 'position'. I also need to be able to use list_filter
> for 'position'. The problem I have is that the data is split between the > built-in User model and UserProfile model. Is there anyway for me to > combine data from two models into a single list view or will I need to > duplicate info such as first_name and last_name into the UserProfile > model and use that list_view? Try a UserProfileAdmin(admin.ModelAdmin) in admin.py and define a method that returns position. Like: class UserProfileAdmin(admin.ModelAdmin): def user_position(self, obj): return obj.get_profile().position list_display = ('username', 'first_name', 'last_name', 'user_position') then reregister your user admin.site.unregister(User) admin.site.register(User, UserProfileAdmin) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---