Wherever you would reference a user instance, reference UserProfile.user instead
If you need to find out a profile from request.user, you can use request.user.get_profile() or the longer UserProfile.objects.get(user_id= request.user.id) Cheers, André On Mon, Jul 11, 2011 at 1:48 PM, Brent <[email protected]> wrote: > Thanks for the responses. > > How do I use a foreign key, though? In other words, how do I tell my > code to look at UserProfile rather than just user? > > On Jul 10, 5:08 am, Jonas Geiregat <[email protected]> wrote: > > Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven: > > > > > > > > > This is not good design. If you want to store some extra fields for a > User - i would define just another model called ProfileDetails, FK it to > User and use it as such. > > > > That's also how I would do it, some example code to make it even more > clear: > > > > from django.db import models > > from django.contrib.auth.models import User > > > > class UserProfile(models.Model): > > user = models.ForeignKey(User, unique=True) > > url = models.URLField("Website", blank=True) > > company = models.CharField(max_length=50, blank=True) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

