On Mon, Feb 16, 2009 at 6:59 PM, Kevin Audleman <kevin.audle...@gmail.com>wrote:

>
> Thanks!
>
> I've got my new User display going and another question has come up.
> In the related MyProfile object, I've got a field called
> payment_status. It's important for my client to be able to quickly
> view a list of users with a payment_status of 'Unpaid.' Is there a way
> to add a related field to the list_display or list_filter sets for the
> User object?
>
> Cheers,
> Kevin
>
> On Feb 16, 3:45 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > On Mon, Feb 16, 2009 at 6:27 PM, Kevin Audleman <
> kevin.audle...@gmail.com>wrote:
> >
> >
> >
> >
> >
> > > I've created a custom profile per the instructions in chapter 12 of
> > > the book to give my user's fields like address1, address2, etc.
> > > Currently when I log in to the admin and want to update a user, I have
> > > to go to two separate pages: the User page to update core user fields,
> > > and the Profile page to update fields in the profiles.
> >
> > > I would like to overwrite the ModelAdmin for the User object and
> > > inline the Profile object so that all fields for a user can be edited
> > > from one page. However django is throwing an error when I try to do
> > > so:
> >
> > > AlreadyRegistered at /admin/
> > > The model User is already registered
> >
> > > Here's the code:
> >
> > > class ProfileInline(admin.TabularInline):
> > >    model = MyProfile
> >
> > > class UserAdmin(admin.ModelAdmin):
> > >    list_display = ('username', 'email', 'first_name', 'last_name',
> > > 'is_staff')
> > >    list_filter = ('is_staff', 'is_superuser')
> > >    inlines = [ProfileInline]
> >
> > > admin.site.register(User, UserAdmin)
> >
> > > Is there a way to do this?
> >
> > > Thanks,
> > > Kevin Audleman
> >
> > Yes just do admin.site.unregister(User) before registering yours.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
You can add it to the list_display by creating a method on the model for it(
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display) and
perhaps use the boolean option to make it more obvious.  Right now you can't
actually use related fields in list_filter:
http://code.djangoproject.com/ticket/3400

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to