Django djStripe订阅服务器\u具有\u活动\u订阅始终为false

Django djStripe订阅服务器\u具有\u活动\u订阅始终为false,django,stripe-payments,Django,Stripe Payments,在当前的djStripe配置上,说: 客户用户模型具有\u活动\u订阅属性 对于在模板内部或其他需要 需要反复检查订阅状态。缓存的\u属性 decorator缓存对象的has\u active\u订阅的结果 实例,优化它以便重用 并要求您添加以下代码: @cached_property def has_active_subscription(self): """Checks if a user has an active subscription.""" return subsc

在当前的djStripe配置上,说:

客户用户模型具有\u活动\u订阅属性

对于在模板内部或其他需要 需要反复检查订阅状态。缓存的\u属性 decorator缓存对象的has\u active\u订阅的结果 实例,优化它以便重用

并要求您添加以下代码:

@cached_property
def has_active_subscription(self):
    """Checks if a user has an active subscription."""
    return subscriber_has_active_subscription(self)
但对我来说,答案总是错误的


发生了什么事?

在查看djStripe的代码后,我提供了两种解决方案,您可以在那里阅读:

def user_has_active_subscription(user):
    warnings.warn("Deprecated - Use ``subscriber_has_active_subscription`` instead. This method will be removed in dj-stripe 1.0.", DeprecationWarning)
    return subscriber_has_active_subscription(user)
那么您必须使用此选项:

@cached_property
def has_active_subscription(self):
    """Checks if a user has an active subscription."""
    return user_has_active_subscription(self)
但这对我来说仍然不起作用,当我还在阅读时,我发现了以下警告:

Helper函数用于检查订阅服务器是否有活动订阅。 如果订阅服务器是AUTH\u USER\u模型的实例,则引发未正确配置的 和get_user_model()。is_anonymous==True

我的问题就是,我从我的个人资料中调用了这个函数,然后这就解决了它:

@cached_property
def has_active_subscription(self):
    """Checks if a user has an active subscription."""
    return user_has_active_subscription(self.user)

更新:我的错误是我当前系统的问题,您可以在此处阅读更多内容: