[Answer]-Django/python: to access defined constant by equivelent string

1👍

You need getattr().

from django.conf import settings

setting_name = "LABEL_NAME"
print(getattr(settings, setting_name))  

0👍

from project import settings
print settings.LABEL_NAME

or

from project.settings import *
print LABEL_NAME

Leave a comment