How to print BASE_DIR from settings.py from django app in terminal? i have the following code in test1.py file:
import os
import django
import settings
print BASE_DIR
but it prints error:
File "test1.py", line 5, in <module>
print BASE_DIR
NameError: name 'BASE_DIR' is not defined
My goal is to write value of BASE_DIR to see what dir is used by Django project.
These commands will help:
python manage.py shell
Then in python shell type:
from django.conf import settings
print(settings.BASE_DIR)
You should print the attribute of the imported module:
print settings.BASE_DIR
Or import this variable from the module:
from settings import BASE_DIR
print BASE_DIR
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With