@
Zzdex @
inoki 两位老哥思路是对的,但是我将 models.DateField 改为 models.DateTimeField 出现了新的错误,下面是报错
Internal Server Error: /topics/1/
Traceback (most recent call last):
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
exception.py", line 35, in inner
response = get_response(request)
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "d:\t_django\t_djangos\
views.py", line 20, in topic
topic = Topic.objects.get(id=topic_id)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 397, in get
num = len(clone)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 254, in __len__
self._fetch_all()
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 62, in __iter__
for row in compiler.results_iter(results):
File "d:\t_django\ll_env\lib\site-packages\django\db\models\sql\
compiler.py", line 1011, in apply_converters
value = converter(value, expression, connection)
File "d:\t_django\ll_env\lib\site-packages\django\db\backends\sqlite3\
operations.py", line 222, in convert_datetimefield_value
value = parse_datetime(value)
File "d:\t_django\ll_env\lib\site-packages\django\utils\
dateparse.py", line 107, in parse_datetime
match = datetime_re.match(value)
TypeError: expected string or bytes-like object
[22/Jul/2018 22:33:12] "GET /topics/1/ HTTP/1.1" 500 101852
Internal Server Error: /topics/1/
Traceback (most recent call last):
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
exception.py", line 35, in inner
response = get_response(request)
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "d:\t_django\ll_env\lib\site-packages\django\core\handlers\
base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "d:\t_django\t_djangos\
views.py", line 20, in topic
topic = Topic.objects.get(id=topic_id)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 397, in get
num = len(clone)
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 254, in __len__
self._fetch_all()
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "d:\t_django\ll_env\lib\site-packages\django\db\models\
query.py", line 62, in __iter__
for row in compiler.results_iter(results):
File "d:\t_django\ll_env\lib\site-packages\django\db\models\sql\
compiler.py", line 1011, in apply_converters
value = converter(value, expression, connection)
File "d:\t_django\ll_env\lib\site-packages\django\db\backends\sqlite3\
operations.py", line 222, in convert_datetimefield_value
value = parse_datetime(value)
File "d:\t_django\ll_env\lib\site-packages\django\utils\
dateparse.py", line 107, in parse_datetime
match = datetime_re.match(value)
TypeError: expected string or bytes-like object