Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 图像上传Django管理员_Python_Django_Sorl Thumbnail - Fatal编程技术网

Python 图像上传Django管理员

Python 图像上传Django管理员,python,django,sorl-thumbnail,Python,Django,Sorl Thumbnail,我是Django的新手,需要通过管理员上传一张图片,以便在我制作的公文包网站上使用。我使用sorl缩略图让图像显示在前端,但是我不知道上传后如何正确调用它们或将它们上传到哪里。这是我的型号.py: from django.db import models # Create your models here. class CaseStudy(models.Model): title = models.CharField(max_length=150) description =

我是Django的新手,需要通过管理员上传一张图片,以便在我制作的公文包网站上使用。我使用sorl缩略图让图像显示在前端,但是我不知道上传后如何正确调用它们或将它们上传到哪里。这是我的
型号.py

from django.db import models

# Create your models here.
class CaseStudy(models.Model):
    title = models.CharField(max_length=150)
    description = models.TextField()
    picture = models.ImageField(upload_to="static")

    def __unicode__(self):
        return self.title #makes title the link in admin
下面是我如何在模板中使用sorl缩略图的示例:

{% thumbnail item.image "100x700" as im %}
<img style="margin:{{ im|margin:"100x700" }}" src="{{ im.url }}" width="{{ im.x }}"     height="{{ im.y }}">
{% endthumbnail %}
{%thumbnail item.image“100x700”作为im%}
{%endthumbnail%}

任何帮助都将不胜感激,因为我是Django noob。

将它们上载到媒体,然后设置媒体服务()