解决Django版本依赖错误
在将Django2.2升级至3.0时,发生了以下错误。
错误 1
ModuleNotFoundError: No module named 'django.contrib.staticfiles.templatetags'
– 起因和解决办法
由于在Django 3.0中,从django.contrib.staticfiles.templatetags.staticfiles导入了static,因此可以将其更改为从django.templatetags.static导入static来解决问题。
错误2
ImportError: cannot import name 'render_to_response'
・问题的原因和解决办法 hé fǎ)
由于在django3.0中,django.shortcuts的render_to_response被改为了render,因此只需将此处更改为render,则问题得以解决。