Python django.utils.html.smart_urlquote() Examples

The following are 5 code examples of django.utils.html.smart_urlquote(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.utils.html , or try the search function .
Example #1
Source File: widgets.py    From bioforum with MIT License 5 votes vote down vote up
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 
Example #2
Source File: widgets.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
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 
Example #3
Source File: widgets.py    From python with Apache License 2.0 5 votes vote down vote up
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 
Example #4
Source File: widgets.py    From python2017 with MIT License 5 votes vote down vote up
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 
Example #5
Source File: rest_framework.py    From Dailyfresh-B2C with Apache License 2.0 5 votes vote down vote up
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