Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 哪里是';化身集';在askbot中定义的用户方法?_Python_Django_Askbot - Fatal编程技术网

Python 哪里是';化身集';在askbot中定义的用户方法?

Python 哪里是';化身集';在askbot中定义的用户方法?,python,django,askbot,Python,Django,Askbot,下面是/askbot/models文件夹中的_init___u;.py文件的一部分: def user_update_avatar_type(self): """counts number of custom avatars and if zero, sets avatar_type to False, True otherwise. The method is called only if avatar application is installed. Saves the object. "

下面是/askbot/models文件夹中的_init___u;.py文件的一部分:

def user_update_avatar_type(self):
"""counts number of custom avatars
and if zero, sets avatar_type to False,
True otherwise. The method is called only if
avatar application is installed.
Saves the object.
"""

if 'avatar' in django_settings.INSTALLED_APPS:
    if self.avatar_set.count() > 0:
        self.avatar_type = 'a'
    else:
        self.avatar_type = _check_gravatar(self.gravatar)
else:
        self.avatar_type = _check_gravatar(self.gravatar)
self.save()
正如您所看到的,在某些情况下,它调用self.avatar\u set.count(),我认为它应该是/Django/Contrib/auth中用户类中的本机方法,或者是由用户添加的方法

但我似乎找不到这种“化身集”方法的定义


谢谢

这是一种反向关系,当您定义指向模型的ForeignKey时,Django会自动添加这种关系。请参阅。

您的答案就在我发布自己的答案之前,我刚刚了解了您的解释。谢谢