I'm using a proxy model of django.contrib.auth.models.User to override
__unicode__ and add some extra methods. This also means that I use my
proxy model class in my ForeignKey and ManyToMany fields. This is all
find and good until I need to use request.user and assign it to an
instance of another of my models. Django tells me that I can't assign
an instance of User where I need an instance of my proxy class. Right
now I'm doing something I'm sure is very inefficient to get around
this:

obj.author = ProxyUser.objects.get(pk=request.user.pk)

That results in an extra hit to the DB.

The other way that seems to work is:

obj.author = ProxyUser(**request.user.__dict__)

I think that should be fine, but it feels hackish. How would you guys
do this?
--~--~---------~--~----~------------~-------~--~----~
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