1.env
- python : 3.8.14
- django version : '4.2.4'
2.Purpose
- Make sure that the static file is saved
- Make sure that the static file can be accessed from the web browser
3.Issue
The problem is that after running django server, the static file can be accessed through url, but not in the unitest environment.
For example, suppose a file is stored in the following path
'MAPPER #<- project dir
|-datasets #<-app name
|-static
|-datasets
|-images
|-Recursion Cellular Image Classification.jpeg
3.1 Access the browser after running the server
- enter the following path into the browser to confirm that it works well. http://localhost:8000/static/datasets/static/datasets/images/Recursion Cellular Image Classification.jpeg
3.2 unittest
- get a 404 status code. and cannot get the image file
from django.test import Client
client = Client()
res_redirect = self.client.get(res.url)
4. try
I tried using requests.get , but i didn't work
requests.get(http://localhost:8000/static/datasets/static/datasets/images/Recursion Cellular Image Classification.jpeg)
5. Question
SO this is my question, how can i access file through url in unittest env