Python 上传图像中的django水印程序

Python 上传图像中的django水印程序,python,django,watermark,Python,Django,Watermark,我正在使用django水印为我的网站图像添加水印。我已经根据此完成了所有设置 这是my settings.py文件(此处仅显示与水印相关的更改) ) 现在根据上面的链接,我已经在我的数据库的水印表中上传了一个透明的PNG图像,即医学艺术,现在我已经在下面的模板中应用了水印,如下所示 {% extends 'base.html'%} {% load watermark %} {% block title %}ShutterStock{%endblock%} {% block content %

我正在使用django水印为我的网站图像添加水印。我已经根据此完成了所有设置

这是my settings.py文件(此处仅显示与水印相关的更改)

)

现在根据上面的链接,我已经在我的数据库的水印表中上传了一个透明的PNG图像,即医学艺术,现在我已经在下面的模板中应用了水印,如下所示

{% extends 'base.html'%}
{% load watermark %}
{% block title %}ShutterStock{%endblock%}


{% block content %}



 <ul> 

{% for photo in photo_list%}
  <li><a href = "{% url 'download_image' photo.id %}"><img src={{photo.photo.url|watermark: 'Medical Art,opacity=40,tile=1'}} alt = 'sample photo' width = '200' height = '200'/></li></a>
{% endfor %}
</ul>





{% endblock %}
{%extends'base.html%}
{%load watermark%}
{%block title%}ShutterStock{%endblock%}
{%block content%}
    {照片列表%中照片的百分比}
  • {%endfor%}
{%endblock%}
在提到,我显示的图像是上传的图像。但我在运行网站后得到以下错误,即

ioat/showphoto错误/


解码器zip不可用

删除
过滤器
和参数之间的空格:

{{photo.photo.url|watermark: 'Medical Art,opacity=40,tile=1'}}
                            ^

例如:

  • 没有空间:

    >>> from django.template import Template, Context
    >>> Template('''{{nothing|default:'HELLO'}}''').render(Context({}))
    u'HELLO'
    
  • 空间:

    >>> Template('''{{nothing|default: 'HELLO'}}''').render(Context({}))
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 125, in __init__
        self.nodelist = compile_string(template_string, origin)
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 153, in compile_string
        return parser.parse()
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 254, in parse
        filter_expression = self.compile_filter(token.contents)
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 360, in compile_filter
        return FilterExpression(token, self)
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 572, in __init__
        self.args_check(filter_name, filter_func, args)
      File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 641, in args_check
        (name, len(nondefs), plen))
    TemplateSyntaxError: default requires 1 arguments, 0 provided
    
    >>>模板(''{{nothing}默认值:'HELLO'}}').render(上下文({}))
    回溯(最近一次呼叫最后一次):
    文件“”,第1行,在
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第125行,在__
    self.nodelist=编译字符串(模板字符串,原点)
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第153行,编译字符串
    返回parser.parse()
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第254行,在解析中
    filter\u expression=self.compile\u过滤器(token.contents)
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第360行,在编译过滤器中
    返回筛选器表达式(令牌、自身)
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第572行,在__
    self.args\u检查(过滤器名称、过滤器函数、args)
    文件“/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site packages/django/template/base.py”,第641行,在参数检查中
    (名称,len(非DEFS),plen)
    TemplateSyntaxError:默认值需要1个参数,提供了0个参数
    

尝试删除空格并使用
引号…现在在/showphoto/decoder zip not处显示此错误IOErroravailable@zogo,该错误似乎是由PIL引发的。请检查url是否引用了有效的图像url。@zogo,请参阅
>>> from django.template import Template, Context
>>> Template('''{{nothing|default:'HELLO'}}''').render(Context({}))
u'HELLO'
>>> Template('''{{nothing|default: 'HELLO'}}''').render(Context({}))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 125, in __init__
    self.nodelist = compile_string(template_string, origin)
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 153, in compile_string
    return parser.parse()
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 254, in parse
    filter_expression = self.compile_filter(token.contents)
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 360, in compile_filter
    return FilterExpression(token, self)
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 572, in __init__
    self.args_check(filter_name, filter_func, args)
  File "/home/falsetru/.virtualenvs/django16/local/lib/python2.7/site-packages/django/template/base.py", line 641, in args_check
    (name, len(nondefs), plen))
TemplateSyntaxError: default requires 1 arguments, 0 provided