简体   繁体   English

ImportError:Django中没有名为函数的模块

[英]ImportError: No module named functions in django

How to add functions in my model? 如何在我的模型中添加功能?

from django.db.models.functions import TruncMonth
ImportError: No module named functions

    report.objects.filter(r_id=id, r_checkin_date__gte=checkin_date)
        .annotate(month=ExtractMonth('timestamp')) 
        .values('month')                          
        .annotate(count=Count('id'))                  
        .values('month', 'count') 

What version on Django are you using: 您正在使用什么版本的Django:

from django.db.models.functions.datetime import TruncMonth is only available in version 1.10 and dev from django.db.models.functions.datetime import TruncMonth仅在版本1.10和dev中可用

here is source code link 这是源代码链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM