Get date from a Django DateTimeField

后端 未结 3 2046
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 23:48

I would like to request some assistance regarding this matter

I am learning django and trying out some codes but I hit a brick wall at trying to get the date only fr

3条回答
  •  攒了一身酷
    2021-01-03 23:54

    SCHEDULED_AT is set to null=True, so sometimes item.SCHEDULED_AT doesn't have value so it's None. If you do a .strftime on None it will have the error you got. null=True means django model allows the field to have NULL value.

    By the way, it's really bad practice to use all upper case for model and field names, model name should be camel case and fields should be lower case with underscore. You model name should be ApplicantData, field name should be scheduled_at.

提交回复
热议问题