I ran into the following problem. I have a model that looks something like this:
class Package(models.Model):
name = models.CharField(max_length=64)
file = models.FileField(upload_to="subdir",
storage=settings.PACKAGE_STORAGE,
null=True)
Essential in this example is the argument storage=to the constructor FileField. It is populated with a value from settings.py. It has the following code:
from django.core.files.storage import FileSystemStorage
PACKAGE_STORAGE = FileSystemStorage(location="/var/data", base_url="/")
For production use, this works great. But in my unit tests, the ones I download are now written to /var/data, which contains the production data. I tried replacing PACKAGE_STOREwith packages/tests.pyas follows
from django.conf import settings
from tempfile import mkdtemp
settings.PACKAGE_STORAGE = FileSystemStorage(location=mkdtemp(), base_url="/")
, , packages , PACKAGE_STORAGE , m, .
?