I am using a conditional statement like this in my code:
if not profile.client.user.id == 3:
Somehow that gives me Exception: Client matching query does not exist.
exception. This is just a conditional operator, so I am not sure why am I getting this exception. Does anyone have any clue what could be going wrong?
UserProfile Model
class UserProfile(models.Model):
# This field is required.
user = models.OneToOneField(User)
client = models.ForeignKey(Client,null=True)
Client Model
class Client(models.Model):
user = models.ForeignKey(AUTH_USER_MODEL, related_name='oauth2_client',
blank=True, null=True)
User Model
This is a standard django user model