[Django]-Checking user type using hasattr()

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 the OneToOneField, Django will use the lower-case name of the current model as default value.

Leave a comment