I’m newcomer in django, and here is question:
I have model class:
def Client(models.User) # django.contrib.auth.User
company_name=models.CharField()
How could I get Client object when I have user object (and user is client)? One way is to filter objects by username:
user=request.user
client=Client.objects.filter(username=user.username)
But I think there is some different and more beautiful method to do this in django, because user is client (they are related one-to-one in database), is one there?
From the documentation on inheritance:
If the
Userinstance is not aClient, you’ll get aClient.DoesNotExistexception.