Open pahaz opened 8 years ago
Example:
class TestFile(models.Model): name = models.CharField(max_length=255, default=get_random_string) file = ProxyStorageFileField(storage=storage)
We have ProxyStorageFileField without upload_to. In this case we can`t find uploaded file =/
ProxyStorageFileField
upload_to
I use this test function for serving files:
def serve_from_storage(request, path): try: file = storage.open(utils.clean_path(path)) except Exception: raise Http404() else: return HttpResponse(file, content_type=guess_type(path)[0]) urlpatterns = patterns( '', url(r'^media/(?P<path>.+)', serve_from_storage), )
Example:
We have
ProxyStorageFileField
withoutupload_to
. In this case we can`t find uploaded file =/I use this test function for serving files: