Python django.core.urlresolvers 模块,get_resolver() 实例源码

我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用django.core.urlresolvers.get_resolver()

项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:geekpoint    作者:Lujinghu    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def get_context_data(self, **kwargs):
        view = self.kwargs['view']
        urlconf = urlresolvers.get_urlconf()
        if urlresolvers.get_resolver(urlconf)._is_callback(view):
            mod, func = urlresolvers.get_mod_func(view)
            view_func = getattr(import_module(mod), func)
        else:
            raise Http404
        title, body, metadata = utils.parse_docstring(view_func.__doc__)
        if title:
            title = utils.parse_rst(title, 'view', _('view:') + view)
        if body:
            body = utils.parse_rst(body, 'view', _('view:') + view)
        for key in metadata:
            metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
        kwargs.update({
            'name': view,
            'summary': title,
            'body': body,
            'meta': metadata,
        })
        return super(ViewDetailView, self).get_context_data(**kwargs)
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    from django.core.urlresolvers import get_resolver
    resolver = get_resolver()
    return check_resolver(resolver)
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:DjangoCMS    作者:farhan711    | 项目源码 | 文件源码
def is_language_prefix_patterns_used():
    """
    Returns `True` if the `LocaleRegexURLResolver` is used
    at root level of the urlpatterns, else it returns `False`.
    """
    return any(isinstance(url_pattern, LocaleRegexURLResolver)
               for url_pattern in get_resolver(None).url_patterns)
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
def check_url_config(app_configs, **kwargs):
    if getattr(settings, 'ROOT_URLCONF', None):
        from django.core.urlresolvers import get_resolver
        resolver = get_resolver()
        return check_resolver(resolver)
    return []
项目:newco-legacy    作者:blaze33    | 项目源码 | 文件源码
def urls_js():
    url_patterns = urlresolvers.get_resolver(None).reverse_dict.items()
    url_list = [(url_name, url_pattern[0][0]) for url_name, url_pattern in url_patterns if isinstance(url_name, basestring)]
    url_list.sort()
    if not re.match(r'^[$A-Z_][\dA-Z_$]*$', JS_VAR_NAME.upper()):
        raise ImproperlyConfigured('JS_REVERSE_JS_VAR_NAME setting "%s" is not a valid javascript identifier.' % (JS_VAR_NAME))
    return render_to_response('django_js_reverse/urls_js.tpl',
                              {
                                  'urls': url_list,
                                  'js_var_name': JS_VAR_NAME
                              },
                              mimetype='application/javascript'
                              )