Is It Possible To Access Static Files Within Views.py?
I am able to access the static file in question via direct url (localhost:8000/static/maps/foo.txt), so I guess I have it all working well. But I can't do the following: I want to
Solution 1:
You need to use the place they are stored on disk, which is probably in settings.STATIC_ROOT
or settings.STATICFILES_DIRS
, not the place they are being served by the web app.
Note however that if you are modifying these files programmatically, they aren't (by definition) static files. You'd be better off using the MEDIA_ROOT
location. Also note that Django has helpers to do this sort of thing - see the documentation on Managing files.
Post a Comment for "Is It Possible To Access Static Files Within Views.py?"