在执行特定的Django查询时获取“Segmentation Fault”

2024-10-01 09:19:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我以前从未遇到过这种情况,但出于某种奇怪的原因,我在Django中运行特定查询时遇到了一个分段错误。在阅读有关分段错误的文章时,似乎这可能与Apache和Python使用的Expat版本有关(而且它们是不同的),但是我不确定的是,为什么它以前从来不是我的问题?我的查询是什么导致它触发那个错误的?在

我希望这是一个错误的查询。有人能解释清楚吗?在

以下查询失败:

def run_account_checks():
    # First, do we have any users with zero PAYG?
    d = datetime.now()
    d = d-timedelta(days=14)
    userprofiles = UserProfile.objects.filter(Q(payg_credits__isnull=True) | Q(payg_credits__lt="3.50"))
    userprofiles = userprofiles.filter(Q(lastemailed_paygempty__lte=d) | Q(lastemailed_paygempty__isnull=True))
    userprofiles = userprofiles.filter(user__supplier__isnull=False)
    for up in userprofiles:
        if up.user and up.user.email:
            # Send email to user

            up.lastemailed_paygempty = datetime.now()
            up.save()

Tags: truedatetimeemail错误filternowcreditsup