Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何定义一个常量,以便在views.py 和models.py 中可用?
您可以将其const.py放入视图和模型中并将其导入。
const.py
views.py 很可能会导入models.py,因此通常建议放入models.py 常量和任何其他代码,以便从views.py、forms.py 或应用程序内的任何其他模块中使用。