如何告訴django-extensions的shell_plus
我想自動加載哪些模型?django-extensions shell_plus autoload
1
A
回答
1
在過去,每當shell_plus不自動加載我的模型時,通常是因爲模型中存在錯誤,導致自動加載失敗。
如果你打開shell plus,然後嘗試手動加載你的模塊一次一個會發生什麼?
from app.models import ModelName
另一件事是嘗試關閉所有的應用程序中,除了在設置文件默認的Django的應用程序,看看他們是否自動加載就好。如果他們這樣做,然後慢慢添加越來越多的應用程序,一次一個,直到它停止工作,然後您可以找出哪個模型有問題。一旦你知道哪個模型存在問題,它將更容易找出正在發生的事情。
最常見的錯誤我是兩種不同的模式之間的循環依賴(這種模式依賴於模型,但它尚未加載,反之亦然)。
希望有所幫助。
1
shell_plus - 的 Django的殼的增強版本。它會自動加載所有 您的模型,使其易於與ORM立即工作 。從Django的擴展GitHub的維基
報價位於https://github.com/django-extensions/django-extensions/wiki/Current-Command-Extensions
不要相信它的實際多變的設計,快速的自動加載ALL模型。
0
根據code。 shell_plus始終加載所有模型。
1
我做了shell_plus擴展,使得可以忽略某些型號新的補丁。等待https://github.com/django-extensions/django-extensions/pull/99獲得接受。
0
默認情況下shell_plus
總是加載所有模型。 感謝@xeor您可以使用該選項SHELL_PLUS_DONT_LOAD您的設置跳過你的一些車型。 您也可以爲您的模型配置別名以避免名稱衝突。
相關問題
- 1. php psr autoload ambiguity
- 2. PHP autoload和set_include_paths
- 3. VideoJS - autoLoad字幕
- 4. jsonObject in store autoLoad
- 5. Google Captcha AutoLoad
- 6. autoload Fancybox image
- 7. Autocad 2018 autoload dll
- 8. ExtJS 4 TreePanel autoload
- 9. Kohana autoload子模型
- 10. php:object autoload - 值得嗎?
- 11. Composer dump-autoload,問題
- 12. Zend Framework 2:Autoload classmap
- 13. RoR autoload子目錄
- 14. Combobox忽略autoLoad [Extjs]
- 15. shell_plus不是自動加載它應該是的所有應用程序
- 16. 腳本IPython中通過Django的shell_plus
- 17. SPL Autoload不加載類
- 18. Codeception autoload:'WebDriver'未定義
- 19. autoload bitbucket存儲庫+ composer.json
- 20. 已安裝Autoload Composer軟件包
- 21. Composer dump-autoload給出preg_match錯誤
- 22. ZF2 config/autoload文件夾內容(ConfigGlobPaths)
- 23. Codeigniter Autoload類在ubuntu中不工作
- 24. extjs4 autoLoad呈現html頁面不工作?
- 25. Symfony Autoload命名空間問題難度
- 26. Z Shell「autoload」builtin - 它有什麼好處?
- 27. psr-4 autoload - 無法重新聲明類
- 28. 如何在php中使用autoload和namespace?
- 29. 有任何C#相當於Perl的AUTOLOAD?
- 30. Kohana autoload無法正常工作
對我來說這不加載任何我的模型。 – 2011-02-05 04:32:47
@ Jason-Swett,您的某個模型可能存在問題,並且導致它們無法正確加載。看看我的答案瞭解更多詳情。 – 2011-02-05 17:19:29