Python django.conf.urls.static 模块,static() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用django.conf.urls.static.static()

项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def static(prefix, view=serve, **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return [
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ]
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def static(prefix, view=serve, **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return [
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ]
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def static(prefix, view=serve, **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return [
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ]
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def static(prefix, view=serve, **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return [
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ]
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def static(prefix, view=serve, **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return [
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ]
项目:CodingDojo    作者:ComputerSocietyUNB    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:NarshaTech    作者:KimJangHyeon    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:Scrum    作者:prakharchoudhary    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)


# Only append if urlpatterns are empty
项目:django    作者:alexsukhrin    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)


# Only append if urlpatterns are empty
项目:Gypsy    作者:benticarlos    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:DjangoBlog    作者:0daybug    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:wanblog    作者:wanzifa    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:tabmaster    作者:NicolasMinghetti    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:trydjango18    作者:lucifer-yqh    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:trydjango18    作者:wei0104    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:ims    作者:ims-team    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:lifesoundtrack    作者:MTG    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:django-open-lecture    作者:DmLitov4    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:travlr    作者:gauravkulkarni96    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:logo-gen    作者:jellene4eva    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:gmail_scanner    作者:brandonhub    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:djanoDoc    作者:JustinChavez    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:CSCE482-WordcloudPlus    作者:ggaytan00    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:tissuelab    作者:VirtualPlants    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view='django.contrib.staticfiles.views.serve')

# Only append if urlpatterns are empty
项目:producthunt    作者:davidgengler    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:django-rtc    作者:scifiswapnil    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)


# Only append if urlpatterns are empty
项目:geekpoint    作者:Lujinghu    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:django-next-train    作者:bitpixdigital    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:LatinSounds_AppEnviaMail    作者:G3ek-aR    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)


# Only append if urlpatterns are empty
项目:DjangoZeroToHero    作者:RayParra    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:Roboism    作者:markroxor    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:django-wechat-api    作者:crazy-canux    | 项目源码 | 文件源码
def staticfiles_urlpatterns(prefix=None):
    """
    Helper function to return a URL pattern for serving static files.
    """
    if prefix is None:
        prefix = settings.STATIC_URL
    return static(prefix, view=serve)

# Only append if urlpatterns are empty
项目:pyconjp-website    作者:pyconjp    | 项目源码 | 文件源码
def gen_urls():
    include_patterns = patterns("",
                                url(r"^$", TemplateView.as_view(template_name="homepage.html"),
                                    name="home"),
                                url(r"^admin/", include(admin.site.urls)),
                                url(r"^account/signup/$", pycon.profile.views.SignupView.as_view(),
                                    name="account_signup"),
                                url(r"^account/login/$", symposion.views.LoginView.as_view(), name="account_login"),
                                url(r"^account/social/", include("social_auth.urls")),
                                url(r"^account/associations/", include("symposion.social_auth.urls")),
                                url(r"^account/", include("account.urls")),
                                url(r"^dashboard/", symposion.views.dashboard, name="dashboard"),
                                url(r"^blog/", include("biblion.urls")),
                                url(r"^force500/", lambda request: xxx),
                                url(r"^registration/", include("pycon.registration.urls")),
                                url(r"^finaid/", include("pycon.finaid.urls")),
                                url(r"^pycon_api/", include("pycon.pycon_api.urls")),
                                url(r"^api/", include("pycon.apis.urls")),
                                url(r"^schedule/", include("pycon.schedule.urls")),
                                url(r"^profile/", include("pycon.profile.urls")),
                                url(r"^tutorials/", include("pycon.tutorials.urls")),

                                url(r"^speaker/", include("symposion.speakers.urls")),
                                url(r"^speaker/list$", speaker_views.speaker_list, name='speaker_list'),
                                url(r"^proposals/", include("pycon.proposals.urls")),
                                url(r"^reviews/", include("symposion.reviews.urls")),
                                url(r"^teams/", include("symposion.teams.urls")),
                                url(r"^schedule/", include("symposion.schedule.urls")),
                                url(r"^conference/", include("symposion.conference.urls")),

                                url(r"^sponsors/", include("pycon.sponsorship.urls")),

                                url(r"^boxes/", include("symposion.boxes.urls")),
                                url(r"^sitemap/", TemplateView.as_view(template_name="static/sitemap.html"),
                                    name="sitemap"),
                                url(r'^selectable/', include('selectable.urls')),
                                url(r"^change_language/", symposion.views.change_language, name="change_language"),
                                url(r"^", include("pycon.urls")),

                                # This should be last, because it will create a new CMS page for
                                # any unrecognized URL.
                                url(r"^", include("restcms.urls")),
                                url(r'^localeurl/', include('localeurlcustom.urls')),
    )

    for key, val in settings.LANGUAGES:
        yield url(r"^%s/%s/" % (URL_PREFIX, key), include(include_patterns))