Have you tried `getattr(u, 'individualprofile', None)` ? 2016-11-26 15:17 GMT+01:00 <eltong...@gmail.com>: > Hi guys > > I'm on Django 1.10, and as described shortly here: https://dpaste.de/Bgao, I > have created an abstract user profile which is tied to Django's User model > with OneToOneField relationship. So I have AbstractProfile, and then there > are IndividualProfile and BusinessProfile, each of which inherits from > AbstractProfile. > > The problem I have, is that, whenever I have a user object instance (i.e. u > = User.objects.get(pk=1234)), I'm not sure how to determine whether the > profile is of type Individual or Business. > > So either u.individualprofile or u.businessprofile throws an error, and > obviously I want to avoid having errors. > > Any help is appreciated. Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/3dac6122-c209-415e-af62-387988c384d3%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout.
-- Cordialement, Coues Ludovic +336 148 743 42 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTaED63APmmgu9KqAdGv%2B7P%2BjBDgyTF9RKUaAor2y7o4DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.