找回密码
 注册
查看: 175|回复: 1

AttributeError: type object 'datetime' has no attribute 'datetime'

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2025-4-28 21:18:57 | 显示全部楼层 |阅读模式
AttributeError: type object 'datetime' has no attribute 'datetime'
& |# _' n! H7 _0 M8 s1 L. _6 [; v, G0 ~9 j- O; r% b, I- b( I
2 _  W: j2 }2 O" t
AttributeError: type object 'datetime' has no attribute 'datetime'  V6 t9 \+ j* Y, h& N0 @
[28/Apr/2025 21:12:45] "GET /hello/test/filter/ HTTP/1.1" 500 69413
/ k7 X- B7 F4 m& L8 _" ?2 @Internal Server Error: /hello/test/filter/( |$ _$ Z+ N2 e+ u6 k( b! n
Traceback (most recent call last):1 R$ E6 N# M. z! Y; \5 `5 }( o
  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\exception.py", line 34, in inner# _& f+ _% a5 i5 F& h; L4 n( }
    response = get_response(request)( H+ ^% y7 M. a4 A: b
  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
8 K+ c% }' a1 R    response = self.process_exception_by_middleware(e, request)
& n7 A+ ~/ Y9 X3 Q/ C' W( ]" U  File "C:\Users\admin\python3.8.2-vitual\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response( R- w2 C3 H8 |) [! u' f' u
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
. N5 K1 V7 n, g! A) j  File "C:\Users\admin\Desktop\testmyproject\hello\views.py", line 160, in test_filter. q% m( L$ L4 T' ^
    my_date = datetime.datetime(2050, 9, 28)
/ d- e& O( k" }$ \3 ^/ r3 e; e9 tAttributeError: type object 'datetime' has no attribute 'datetime': i8 f4 @- \4 x/ m4 d
! M/ z" O1 @" z( K/ h* h

+ }8 v  t0 ^* j4 I, d6 u2 M/ g# u" h# \: M

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2025-4-28 21:23:11 | 显示全部楼层
解决办法:. O% }) ~$ ]. a! Y
调整引入时间的参数:( q- e; o; I% u4 u# v9 Y
from datetime import datetime    这个参数不可以成功,6 O9 d. T& z3 s; G" S$ f
import datetime    引入这个参数即可正常获取时间。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-11 23:16 , Processed in 0.020372 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表