本文整理汇总了Python中django.utils.html.smart_urlquote方法的典型用法代码示例。如果您正苦于以下问题:Python html.smart_urlquote方法的具体用法?Python html.smart_urlquote怎么用?Python html.smart_urlquote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.utils.html
的用法示例。
在下文中一共展示了html.smart_urlquote方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context
# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import smart_urlquote [as 别名]
def get_context(self, name, value, attrs):
context = super().get_context(name, value, attrs)
context['current_label'] = _('Currently:')
context['change_label'] = _('Change:')
context['widget']['href'] = smart_urlquote(context['widget']['value']) if value else ''
return context
示例2: get_context
# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import smart_urlquote [as 别名]
def get_context(self, name, value, attrs):
context = super(AdminURLFieldWidget, self).get_context(name, value, attrs)
context['current_label'] = _('Currently:')
context['change_label'] = _('Change:')
context['widget']['href'] = smart_urlquote(context['widget']['value']) if value else ''
return context
示例3: smart_urlquote_wrapper
# 需要导入模块: from django.utils import html [as 别名]
# 或者: from django.utils.html import smart_urlquote [as 别名]
def smart_urlquote_wrapper(matched_url):
"""
Simple wrapper for smart_urlquote. ValueError("Invalid IPv6 URL") can
be raised here, see issue #1386
"""
try:
return smart_urlquote(matched_url)
except ValueError:
return None