Unable to access UserProfile model fields in templates in Django

0 votes

I'm storing some additional per-user information using the AUTH_PROFILE_MODULE.

We can access the user in a Django template using {{ request.user }} but how do we access fields in the profile since the profile is only accessible via a function user.get_profile() ?

Nov 12, 2020 in Python by Niroj
• 82,880 points
546 views

1 answer to this question.

0 votes

Use {{ request.user.get_profile.whatever }}. Django's templating language automatically calls things that are callable - in this case, the .get_profile() method.

answered Nov 13, 2020 by Gitika
• 65,890 points

Related Questions In Python

0 votes
1 answer

How to extend the User model with custom fields in Django?

Hello @kartik, Define an object manager for your ...READ MORE

answered Aug 3, 2020 in Python by Niroj
• 82,880 points
3,091 views
0 votes
1 answer

How to get all related Django model objects in Python?

This actually gives you the property names ...READ MORE

answered Nov 14, 2018 in Python by Nymeria
• 3,560 points

edited Dec 18, 2018 by Nymeria 6,774 views
0 votes
1 answer

How to Specify a mySQL ENUM in a Django model?

Hello @kartik, You can follow this snippet below: MAYBECHOICE ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,880 points
1,432 views
0 votes
1 answer
0 votes
1 answer

Unable to create a project in django.

I think u didn't install Django. python -m ...READ MORE

answered Nov 12, 2020 in Python by Gitika
• 65,890 points
716 views
0 votes
1 answer

How to access a module written in Python from C?

Hey, @Roshni: You can access a module written ...READ MORE

answered Jun 26, 2020 in Python by Gitika
• 65,890 points
2,550 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP