django - 'None type' object has no attribute 'year' -


i'm trying year datetime form i'm getting error when run project code 'none type' object has no attribute 'year' i've tried both import datetime , from datetime import datetime no success. although in function placed before 1 in same file views.py wrote same code (of year getting...) , works well! ps: when run code on ipdb shell works correctly! code:

from datetime import datetime def my_function(request):     data = tablea.find()     dt = datetime.now()     y = dt.year     m = dt.month     d = dt.day     in data:         if i['ma_date'].year == y:              ma_liste.append([i["ma_date"]) return render(request, ma_page.html, ma_liste) 

and erreor

**attributeerror @ /ma_page/ 'nonetype' object has no attribute 'year'** 

this has nothing datetime. data item has no year attribute.

you haven't shown code or structure object, it's it's multidimensional array, in case use: i['ma_date']['year'].


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -