Showing user's data on page

27 views
Skip to first unread message

Branko Zivanovic

unread,
Jan 2, 2017, 6:57:06 AM1/2/17
to Django users
I've created custom user model which has OneToOneField which relates to original auth User model. In my template, I have to access data from custom model, but I use user.is_authenticated() and original model doesn't have reference to custom model. I'm not sure if I'm checking login incorrectly or accessing data.


Code

Daniel Roseman

unread,
Jan 2, 2017, 7:16:20 AM1/2/17
to Django users
This isn't a custom user model, it's a related model - what would normally be called a user profile.

Regardless, there *is* a reference from User to CustomUser, via the one-to-one relation: you can just do `user.customuser`.

--
DR.

Branko Zivanovic

unread,
Jan 2, 2017, 10:39:06 AM1/2/17
to Django users
Thank you very much Sir, that worked!
Happy New Year, all the best!

Branko
Reply all
Reply to author
Forward
0 new messages