4👍
✅
You’re almost there – you just need to use lowercase studentprofile
instead of StudentProfile
:
hasattr(request.user, 'studentprofile')
From the docs:
If you do not specify the
related_name
argument for theOneToOneField
, Django will use the lower-case name of the current model as default value.
Source:stackexchange.com