> I'm using the django User authentication.
>
> I have a model that has a ManyToManyField which allows you to select
> several users to associate with that model. In the django admin site,
> it's set to use the filter_horizontal option.
>
> When adding a new instance of the model through the admin interface,
> it shows you the username of the User. I would like it to show the
> first_name and last_name instead. I tried using a Proxy Model and
> changing the __unicode__(self) with no success, it still shows the
> username in the admin site. I also tried inheriting from the User
> class, but it did not work either and I would rather not do it that
> way.
>
> I'm a relative noob at django, so I could very easily be missing
> something simple. Any suggestions?
The proxy model didn't work because Django has no way of knowing you
want the proxy class, rather than the base User class.
There's a hook in ModelAdmin to that allows you to specify this sort
of thing - formfield_for_foreignkey. See the documentation here:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
You could almost use that example exactly, returning your proxy class
in the queryset kwarg.
--
DR.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment