Skip to content

Commit cf781bb

Browse files
committed
修改默认的imagefiled返回路径,
1 parent 627e30b commit cf781bb

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

fast_tmp/contrib/tortoise/fields.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ def __init__(self, path: str):
1515
self.path = path
1616

1717
def get_file(self):
18-
from fast_tmp.conf import settings
19-
2018
if self.path is not None:
21-
value = os.path.join(os.getcwd(), settings.MEDIA_PATH, self.path)
19+
value = os.path.join(os.getcwd(), self.path)
2220
return UploadFile(filename=value)
2321
return None
2422

@@ -29,19 +27,12 @@ def __str__(self):
2927
return self.path
3028

3129
def get_static_path(self):
32-
from fast_tmp.conf import settings
33-
34-
return "/" + "/".join([settings.MEDIA_ROOT, self.path])
30+
return self.path
3531

3632
@classmethod
3733
def from_static_path(cls, path: str):
38-
from fast_tmp.conf import settings
39-
4034
if not path:
4135
return None
42-
if path.startswith("/" + settings.MEDIA_ROOT): # 去除静态头
43-
header_len = len(settings.MEDIA_ROOT) + 2
44-
path = path[header_len:]
4536
return cls(path)
4637

4738
def __len__(self):

0 commit comments

Comments
 (0)