Django User model, adding function
Posted
by Hellnar
on Stack Overflow
See other posts from Stack Overflow
or by Hellnar
Published on 2010-05-30T19:13:53Z
Indexed on
2010/05/30
19:22 UTC
Read the original article
Hit count: 460
Hello, I want to add a new function to the default User model of Django for retrieveing a related list of Model type.
Such Foo model:
class Foo(models.Model):
owner = models.ForeignKey(User, related_name="owner")
likes = models.ForeignKey(User, related_name="likes")
........
#at some view
user = request.user
foos= user.get_related_foo_models()
Hwo can this be achieved ?
© Stack Overflow or respective owner