Get the App
SLTechnology News&Howtos  ›  Development  › 

How Django uses relative paths in configuration

Shulou Source: shulou.com Published: 2022-06-01 04:09:47 11月16日 Update

This article mainly introduces how to use the relative path in the configuration of Django, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.

Use relative paths in configuration

For some reason, projects may often be moved back and forth. This is definitely a thorny problem if this possibility is not planned in advance. Rob Hudson has an excellent technique to ensure that your Django project can be easily migrated back and forth during deployment. Just write a few lines of code in your settings.py.

Import osBASE_DIR = os.path.dirname (os.path.abspath (_ file__)) TEMPLATE_DIRS = (BASE_DIR +'/ templates',) Thank you for reading this article carefully. I hope the article "how to use relative paths in Django configuration" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Configuration articles paths projects excellent tricky code value interests reasons possibilities at the same time skills documents more friends knowledge editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Information Linux Huawei Microsoft