On 17-Mar-09, at 9:46 AM, Paolo Corti wrote:
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1) # Get the first user in the system
> user_address = u.get_profile().home_address
>
> but is there a way to access to UserProfile in the view?

Do you mean in the template?

The view is python and you can access the profile just as you do so

> supposing the UserProfile model is called myprofile, this will not do
> the trick:
>
> {{ user.myprofile.home_address }}

I don't use Django templating but have you tried:

user.get_profile.home_address

Not sure why you'd be using myprofile there where in python you used  
get_profile.
--
   Andy McKay
   Clearwind Consulting: www.clearwind.ca
   Blog: www.agmweb.ca/blog/andy
   Twitter: twitter.com/clearwind


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

Reply via email to