[Answered ]-Manager isn't accessible via SocialToken instances

2đź‘Ť

âś…

The error you’re getting is telling you quite a bit. “Manager” refers to Model.objects, so somewhere you’re trying to access .objects on a single SocialToken.

My guess is that somewhere in your code you have something like the following:

SocialToken = SocialToken.objects.first()  # This isn't good!
...
tokens = SocialToken.objects.all()  # This will cause your error

Here, because SocialToken refers to an instance rather than your model, you won’t be able to access SocialToken.objects, your manager.

You’ve done this with SocialAccount in the code you pasted above. Use something like social_account rather than SocialAccount to refer to an individual account:

social_accounts = SocialAccount.objects.filter(provider='facebook')
for social_account in social_accounts:
    socialtokens = SocialToken.objects.filter(id=social_account.id)

Go through your code and see if you have any CapWords instances and rename them so they’re separated_with_underscores. See the Python Style Guide for more information on class/instance/variable naming conventions (it’s a good read!).

👤Franey

Leave a comment