1👍
Two ways to do it…
-
If you define
STATIC_ROOT = os.path.join(PROJECT_DIR,'static')
in settings.py file then you can access the static directory like/commands/mycommand.py from django.conf import settings pprint.pprint(settings.STATIC_ROOT)
-
Or import static object
/commands/mycommand.py from django.templatetags.static import static url = static('myapp/myfile.txt')
Source:stackexchange.com