現在の日付と前の日付の日差を計算したいと思います。私はこのコードdjangoの2つの日付間のdiffを計算する方法
requiremntObj = CustomerLeads.objects.all()
a = datetime.datetime.now().date()
for i in requiremntObj:
date1=i.posting_date
diff = a-date1
print diff
をしようとしています 私は私がDateTimeオブジェクトを取得しています現在の日付の場合はエラーにunsupported operand type(s) for -: 'datetime.date' and 'unicode'
を持って、日付1のために、私はユニコードを取得しています。
posting_date = models.DateField()
は '投稿用日付' 'CharField'または' DateTimeField'ですか? – Hybrid
'CustomerLeads'モデルはどのように見えますか? 'posting_date'は適切ですか?[DateTimeField](https://docs.djangoproject.com/ja/1.10/ref/models/fields/#datetimefield)?そうでない場合:モデルを修正してください! – dhke