django의 staticfile 찾기가 정적 리소스를 찾을 수 있는지 알고 싶습니다.
앱 이름은 my_app
입니다. 그 안에 static
폴더가 있습니다. 정적 리소스가 들어있는 my_app
이라는 폴더가 다시 있는데 'test.jpg'라는 이미지가 있다고 가정 해 보겠습니다.
myapp
|-- __init__.py
`-- models.py
`-- static
`-- myapp
`-- test.jpg
from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage
class TestStaticFiles(TestCase):
"""Check if app contains required static files"""
def test_images(self):
abs_path = finders.find('myapp/test.jpg')
self.assertTrue(staticfiles_storage.exists(abs_path))
finders
모든 응용 프로그램의 static/
하위 디렉토리가 정적 자원을 찾기 위해 내부 보인다.