django - Manager isn't accessible via SocialToken instances -


something weird happening script, i've been debugging day , haven't gotten anywhere. i've searched far , wide , nothing solved issue, title might misleading that's error get.

i'm using django-allauth, have socialaccounts , socialtokens

    socialaccounts = socialaccount.objects.filter(provider='facebook')     socialaccount in socialaccounts:         socialtokens = socialtoken.objects.filter(id=socialaccount.id)         socialtoken in socialtokens:             #get few values, set few values             #at end update or create custom model             obj, created = facebookpageslist.objects.update_or_create(user=p.user, page_id=p.page_id, uid=p.uid, defaults = updated_values) 

i have debugged several times, works fine when runs once, ie limit socialaccount list user filter 1 user , works properly, 2nd user , works fine too. far 2 users ones in db. when remove user filter goes through 1st user , populates model, fails on 2nd user.

idk else try. here model.

class facebookpageslist(models.model): user = models.foreignkey(socialaccount) page_id = models.charfield('page id', max_length=255) page_name = models.charfield('page name', max_length=255) page_access_token = models.textfield('page token') page_category = models.charfield('page category', max_length=100) uid = models.charfield('fb user id',max_length=255) perms = models.textfield('permissions') getdata = models.booleanfield('pull data?', default=true, null=false) dateadded = models.datetimefield('date added', default=timezone.now) datemodified = models.datetimefield('date modified', default=timezone.now) lastdatapull = models.datetimefield('last data pulled', default='1990-01-01 00:00:00') #id = models.integerfield('id', default=0, primary_key=true)  def __str__(self):     return self.page_name  class meta:     unique_together = ('user', 'page_id') 

the error you're getting telling quite bit. "manager" refers model.objects, somewhere you're trying access .objects on single socialtoken.

my guess somewhere in code have following:

socialtoken = socialtoken.objects.first()  # isn't good! ... tokens = socialtoken.objects.all()  # cause error 

here, because socialtoken refers instance rather model, won't able access socialtoken.objects, manager.

you've done socialaccount in code pasted above. use social_account rather socialaccount refer individual account:

social_accounts = socialaccount.objects.filter(provider='facebook') social_account in social_accounts:     socialtokens = socialtoken.objects.filter(id=social_account.id) 

go through code , see if have capwords instances , rename them they're separated_with_underscores. see the python style guide more information on class/instance/variable naming conventions (it's read!).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -