关于加载django模块时的错误:no module named django.conf.urls.defaults
生活随笔
收集整理的這篇文章主要介紹了
关于加载django模块时的错误:no module named django.conf.urls.defaults
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
我們在嘗試安裝調(diào)試graphite webapp時,或者使用django制作網(wǎng)站時會遇見此問題。或者類似的問題.
File?"/opt/graphite/webapp/graphite/urls.py",?line?15,?in?<module>from?django.conf.urls.defaults?import?*ImportError:?No?module?named?defaults原因在于:Django 1.6 時改變了模塊結(jié)構(gòu),原先的defaults模塊被去除了。為了解決這一問題你有兩種方式。
1:回滾到1.5.x版本上
2:找到代碼問題行,將此行改為
from?django.conf.urls?import?patterns,?url,?include相信能解決你的問題
如果你是在調(diào)試暗轉(zhuǎn)graphite webapp時遇見此問題,下列的Python腳本能夠一次性修復(fù)所有的有問題的模塊.
python?scirpte?name:?fixerrorNomodule.pyimport?re files?=?["/opt/graphite/webapp/graphite/urls.py", "/opt/graphite/webapp/graphite/urls.py", "/opt/graphite/webapp/graphite/render/urls.py", "/opt/graphite/webapp/graphite/cli/urls.py", "/opt/graphite/webapp/graphite/composer/urls.py", "/opt/graphite/webapp/graphite/metrics/urls.py", "/opt/graphite/webapp/graphite/browser/urls.py", "/opt/graphite/webapp/graphite/account/urls.py", "/opt/graphite/webapp/graphite/dashboard/urls.py", "/opt/graphite/webapp/graphite/whitelist/urls.py", "/opt/graphite/webapp/graphite/graphlot/urls.py", "/opt/graphite/webapp/graphite/version/urls.py", "/opt/graphite/webapp/graphite/events/urls.py"] files2=?["/opt/graphite/webapp/graphite/urls.py"] str?=?'from?django.conf.urls.defaults?import?*\n' for?file?in?files:?print?filef?=?open(file,?"r+")flists?=?f.readlines()print?len(flists),for?i?in?range(len(flists)):if?flists[i]?==?str:print?flists[i]flists[i]?=?"from?django.conf.urls?import?patterns,?url,?include?\n"else:passf?=?open(file,?"w+")f.writelines(flists)f.close()轉(zhuǎn)載于:https://blog.51cto.com/zicowarn/1542790
《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的关于加载django模块时的错误:no module named django.conf.urls.defaults的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 上传照片表单提交包括文本框下拉条等,如何
- 下一篇: Lua 函数、闭包、尾调用总结