connection.ops.date_trunc_sql() 方法详解

官网文档上没有找到详细的解释,谁举个例子帮忙解释下

阅读 5.1k
2 个回答

问的如此简单草率,把困难留给别人。
好待你也要这样啊, 装一个开发工具pycharm,点进去源码看解释

from django import db
db.connection.ops.date_trunc_sql()
def date_trunc_sql(self, lookup_type, field_name):
    """
    Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
    truncates the given date field field_name to a date object with only
    the given specificity.
    """
推荐问题