示例#1
0
    def urls(self):

        urlpatterns = [
            url(regex=r'^$', view=self.list_view, name='list'),
            url(regex=r'^(?P<module>.+)/(?P<preview>.+)/$',
                view=self.detail_view,
                name='detail'),
        ]

        if not is_django_version_greater_than_1_9:
            urlpatterns = patterns('', urlpatterns)

        if not should_use_staticfiles():
            url_staticsfiles = [
                url(regex=r'^static/(?P<path>.*)$',
                    view=django.views.static.serve,
                    kwargs={
                        'document_root':
                        os.path.join(os.path.dirname(__file__), 'static'),
                    },
                    name='static')
            ]

            if is_django_version_greater_than_1_9:
                urlpatterns += url_staticsfiles
            else:
                urlpatterns += patterns('', url_staticsfiles)
        return include(urlpatterns, namespace=URL_NAMESPACE)
示例#2
0
def mailviews_static(path):
    if should_use_staticfiles():
        from django.contrib.staticfiles.templatetags import staticfiles
        return staticfiles.static(path)
    else:
        from django.core.urlresolvers import reverse
        return reverse('%s:static' % URL_NAMESPACE, kwargs={
            'path': path,
        })
def mailviews_static(path):
    if should_use_staticfiles():
        from django.contrib.staticfiles.templatetags import staticfiles
        return staticfiles.static(path)
    else:
        from django.urls import reverse
        return reverse('%s:static' % URL_NAMESPACE, kwargs={
            'path': path,
        })
示例#4
0
    def urls(self):

        urlpatterns = [
            url(regex=r"^$", view=self.list_view, name="list"),
            url(regex=r"^(?P<module>.+)/(?P<preview>.+)/$", view=self.detail_view, name="detail"),
        ]

        if not should_use_staticfiles():
            url_staticsfiles = [
                url(
                    regex=r"^static/(?P<path>.*)$",
                    view=django.views.static.serve,
                    kwargs={"document_root": os.path.join(os.path.dirname(__file__), "static")},
                    name="static",
                )
            ]

            urlpatterns += url_staticsfiles

        return include(urlpatterns, namespace=URL_NAMESPACE)
示例#5
0
    def urls(self):
        urlpatterns = [
            url(regex=r'^$', view=self.list_view, name='list'),
            url(regex=r'^(?P<module>.+)/(?P<preview>.+)/$',
                view=self.detail_view,
                name='detail'),
        ]

        if not should_use_staticfiles():
            urlpatterns += [
                url(regex=r'^static/(?P<path>.*)$',
                    view='django.views.static.serve',
                    kwargs={
                        'document_root':
                        os.path.join(os.path.dirname(__file__), 'static'),
                    },
                    name='static'),
            ]

        return include(urlpatterns, namespace=URL_NAMESPACE)
示例#6
0
    def urls(self):
        urlpatterns = patterns('',
            url(regex=r'^$',
                view=self.list_view,
                name='list'),
            url(regex=r'^(?P<module>.+)/(?P<preview>.+)/$',
                view=self.detail_view,
                name='detail'),
        )

        if not should_use_staticfiles():
            urlpatterns += patterns('',
                url(regex=r'^static/(?P<path>.*)$',
                    view='django.views.static.serve',
                    kwargs={
                        'document_root': os.path.join(os.path.dirname(__file__), 'static'),
                    },
                    name='static'),
                )

        return include(urlpatterns, namespace=URL_NAMESPACE)