434👍
✅
Try with this: from django.conf import settings
then
settings.VARIABLE
to access that variable.
VARIABLE should be in capital letter. It will not work otherwise.
131👍
from django.conf import settings
PRIVATE_DIR = getattr(settings, "PRIVATE_DIR", None)
Where it says None
, you will put a default value incase the variable isn’t defined in settings.
- [Django]-Django: Record with max element
- [Django]-Define css class in django Forms
- [Django]-Django: Reference to an outer query may only be used in a subquery
4👍
There’s an example of importing the EMAIL_HOST_USER
from the settings.py file and use it to send an email:
from django.conf import settings
from django.core.mail import send_mail
def post_share(request, post_id):
# ...
send_mail(subject, message, settings.EMAIL_HOST_USER, [
settings.EMAIL_HOST_USER, 'ahmnouira@gmail.com'])
- [Django]-Nginx doesn't serve static
- [Django]-Django Admin – Disable the 'Add' action for a specific model
- [Django]-Django-reversion and related model
Source:stackexchange.com