Skip to content

How to get account given user and using base models? #232

Answered by simkimsia
simkimsia asked this question in Q&A
Discussion options

You must be logged in to vote

Both models above are in the app called core in Django 3.2

So what I did is I have a function in core/services.py

def get_account_by_user(user: CustomUser) -> Account:
    """
    given CustomUser, get the associated Account via core_accountuser relation
    """
    return user.core_accountuser.first().organization

see #233 for an application of this method

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simkimsia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant