通常的做法是在CKEDITOR_UPLOAD_PATH = 'uploads/'
中定义settings.py
。但这将以唯一的路径保存所有模型中的图像。是否可以为每个模型分配不同的图像路径?
class BlogModel(models.Model):
......
content = RichTextUploadingField() # image upload to /media/blog/
class NewsModel(models.Model):
......
content = RichTextUploadingField() # image upload to /media/news/
答案 0 :(得分:0)
您可以使用FileField i.putExtra("comment", commentname.getText().toString());
upload_to='pathname'
博客模型内容将上传到class BlogModel(models.Model)
content = models.FileField(upload_to='blog/')
class NewsModel(models.Model)
content = models.FileField(upload_to='news/')
新闻模型内容将上传到/media/blog/
您也可以这样做:
/media/news/
将另存为content = models.FileField(upload_to='pathname/%Y/%m/%d/')