English 中文(简体)
Django queryfil, 过了一个日期,结果产生于LQ的一个无效的辛塔
原标题:Django query filter, passing a date results in an invalid SQL syntax
z = Pokes.objects.filter(
    pokestiming__when_start__lte=datetime.now(), 
    pokestiming__when_end__gte=datetime.now(),
    pokestiming__next_poke__lte=datetime.now(),
    poke_deleted=0,
    poke_operating=1,
)

这是一种使用Im的 que。 它选择了任何烟 object物体,在日期范围内选择波克塔提(外国钥匙)。 它基本上是一个起始日期和到期日。

问题在于,时间过长,尽管在QQQQKinggo docs中似乎完全是同一个辛迪加,但结果是:

缩略语 INNER JOIN pokes_timing ON (.id = pokes_timing. poke_id WHERE (pokes.>.poke_deleted = 0 and . < = 2010-02-01 00:00 and pokes_timing <>code>>>>>.next_poke . >.

这就是说,所通过日期只是日期,而不是插图,造成错误,没有结果。 http://docs.djangoproject.com/en/dev/faq/models/#how-can-i-see-the-raw-sql-queries-django-is-running”rel=“nofollow noreferer” 这种方法

我确信,我有一米没有sil的东西。


Models:
class Pokes(models.Model):
    poke_title = models.CharField(max_length=135)
    poke_text = models.TextField()
    poke_email = models.CharField(max_length=450)
    poke_email_verified = models.IntegerField(null=True, blank=True)
    poke_key = models.CharField(max_length=30)
    poke_operating = models.IntegerField(default=0)
    poke_deleted = models.IntegerField(default=0)

    class Meta:
        db_table = u pokes 

    def __unicode__(self):
        return self.poke_title

class PokesTiming(models.Model):
    poke = models.ForeignKey(Pokes)
    interval_min = models.IntegerField(null=True, default=30)
    interval_max = models.IntegerField(null=True, default=120)
    when_start = models.DateTimeField()
    when_end = models.DateTimeField()
    last_run = models.DateTimeField()
    is_single = models.IntegerField(default=0)
    next_poke = models.DateTimeField()

    class Meta:
        db_table = u pokes_timing 

    def __unicode__(self):
        return self.poke

Bah-Must只是我。 现在似乎通过Django进行工作(测试数据,我必须错过——现在回报结果),但“Kingk”的原始格工没有工作。 我猜想Django在处决之前会做些什么? 这似乎有两种工作方式。

问题回答

Django将永远把所有领域投入到适当的SQyntaxe,在你手工作业时,你可能不会这样做。 因此,你有错误。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...