当前位置: 首页>>代码示例>>Python>>正文


Python settings.STATIC_URL属性代码示例

本文整理汇总了Python中django.conf.settings.STATIC_URL属性的典型用法代码示例。如果您正苦于以下问题:Python settings.STATIC_URL属性的具体用法?Python settings.STATIC_URL怎么用?Python settings.STATIC_URL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在django.conf.settings的用法示例。


在下文中一共展示了settings.STATIC_URL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def index(request, **kwargs):
    bundle = webpack_manifest.load(
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), '../ui-tracker.manifest.json')
        ),
        settings.STATIC_URL,
        debug=settings.DEBUG,
        timeout=60,
        read_retry=None,
    )

    return render(
        request,
        'ui/index.html',
        {
            'event': Event.objects.latest(),
            'events': Event.objects.all(),
            'bundle': bundle.tracker,
            'CONSTANTS': mark_safe(json.dumps(constants())),
            'ROOT_PATH': reverse('tracker:ui:index'),
            'app': 'TrackerApp',
            'form_errors': {},
            'props': '{}',
        },
    ) 
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:27,代码来源:views.py

示例2: media

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def media(request):
    """
    Add context things that we need
    """
    # A/B testing: half of instructors and TAs see a different search box
    instr_ta = is_instr_ta(request.user.username)
    instr_ta_ab = instr_ta and request.user.is_authenticated and request.user.id % 2 == 0
    # GRAD_DATE(TIME?)_FORMAT for the grad/ra/ta apps
    return {'GRAD_DATE_FORMAT': settings.GRAD_DATE_FORMAT,
            'GRAD_DATETIME_FORMAT': settings.GRAD_DATETIME_FORMAT,
            'LOGOUT_URL': settings.LOGOUT_URL,
            'LOGIN_URL': settings.LOGIN_URL,
            'STATIC_URL': settings.STATIC_URL,
            'is_instr_ta': instr_ta,
            'instr_ta_ab': instr_ta_ab,
            'request_path': request.path,
            'CourSys': product_name(request),
            'help_email': help_email(request),
            } 
开发者ID:sfu-fas,项目名称:coursys,代码行数:21,代码来源:context.py

示例3: get_static_prefix

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def get_static_prefix(parser, token):
    """
    Populates a template variable with the static prefix,
    ``settings.STATIC_URL``.

    Usage::

        {% get_static_prefix [as varname] %}

    Examples::

        {% get_static_prefix %}
        {% get_static_prefix as static_prefix %}

    """
    return PrefixNode.handle_token(parser, token, "STATIC_URL") 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:18,代码来源:static.py

示例4: do_static

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def do_static(parser, token):
    """
    Joins the given path with the STATIC_URL setting.

    Usage::

        {% static path [as varname] %}

    Examples::

        {% static "myapp/css/base.css" %}
        {% static variable_with_path %}
        {% static "myapp/css/base.css" as admin_base_css %}
        {% static variable_with_path as varname %}

    """
    return StaticNode.handle_token(parser, token) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:19,代码来源:static.py

示例5: get_context_data

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def get_context_data(self, parent_context, *tag_args, **tag_kwargs):
        """
        The main logic for the inclusion node, analogous to ``@register.inclusion_node``.
        """
        target_object = tag_args[0]  # moved one spot due to .pop(0)
        new_context = {
            'STATIC_URL': parent_context.get('STATIC_URL', None),
            'USE_THREADEDCOMMENTS': appsettings.USE_THREADEDCOMMENTS,
            'target_object': target_object,
        }

        # Be configuration independent:
        if new_context['STATIC_URL'] is None:
            try:
                request = parent_context['request']
            except KeyError:
                new_context.update({'STATIC_URL': settings.STATIC_URL})
            else:
                new_context.update(context_processors.static(request))

        return new_context 
开发者ID:82Flex,项目名称:DCRM,代码行数:23,代码来源:fluent_comments_tags.py

示例6: do_static

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def do_static(parser, token):
    """
    Join the given path with the STATIC_URL setting.

    Usage::

        {% static path [as varname] %}

    Examples::

        {% static "myapp/css/base.css" %}
        {% static variable_with_path %}
        {% static "myapp/css/base.css" as admin_base_css %}
        {% static variable_with_path as varname %}
    """
    return StaticNode.handle_token(parser, token) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:18,代码来源:static.py

示例7: check_settings

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def check_settings(base_url=None):
    """
    Check if the staticfiles settings have sane values.
    """
    if base_url is None:
        base_url = settings.STATIC_URL
    if not base_url:
        raise ImproperlyConfigured(
            "You're using the staticfiles app "
            "without having set the required STATIC_URL setting.")
    if settings.MEDIA_URL == base_url:
        raise ImproperlyConfigured("The MEDIA_URL and STATIC_URL "
                                   "settings must have different values")
    if ((settings.MEDIA_ROOT and settings.STATIC_ROOT) and
            (settings.MEDIA_ROOT == settings.STATIC_ROOT)):
        raise ImproperlyConfigured("The MEDIA_ROOT and STATIC_ROOT "
                                   "settings must have different values") 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:19,代码来源:utils.py

示例8: run

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def run(self, lines):
        new_lines = []

        def emojify(match):
            emoji = match.group(1)

            if not emoji in emojis_set:
                return match.group(0)

            image = emoji + u'.png'
            url = os.path.join(settings.STATIC_URL, u'spirit', u'emojis', image).replace(u'\\', u'/')

            return u'![%(emoji)s](%(url)s)' % {'emoji': emoji, 'url': url}

        for line in lines:
            if line.strip():
                line = re.sub(ur':(?P<emoji>[a-z0-9\+\-_]+):', emojify, line, flags=re.UNICODE)

            new_lines.append(line)

        return new_lines 
开发者ID:SPARLab,项目名称:BikeMaps,代码行数:23,代码来源:emoji.py

示例9: __call__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def __call__(self, request):
        response = self.get_response(request)

        if (len(connection.queries) == 0 or
                request.path_info.startswith('/favicon.ico') or
                request.path_info.startswith(settings.STATIC_URL) or
                request.path_info.startswith(settings.MEDIA_URL)):
            return response

        indentation = 2
        print(("\n\n%s\033[1;35m[SQL Queries for]\033[1;34m %s\033[0m\n" % (" " * indentation, request.path_info)))
        total_time = 0.0
        for query in connection.queries:
            if query['sql']:
                nice_sql = query['sql'].replace('"', '').replace(',', ', ')
                sql = "\033[1;31m[%s]\033[0m %s" % (query['time'], nice_sql)
                total_time = total_time + float(query['time'])
                print(("%s%s\n" % (" " * indentation, sql)))
        replace_tuple = (" " * indentation, str(total_time), str(len(connection.queries)))
        print(("%s\033[1;32m[TOTAL TIME: %s seconds (%s queries)]\033[0m" % replace_tuple))
        return response 
开发者ID:SubstraFoundation,项目名称:substra-backend,代码行数:23,代码来源:sql_printing_middleware.py

示例10: send_email

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def send_email(to, kind, cc=[], **kwargs):

    current_site = Site.objects.get_current()

    ctx = {"current_site": current_site, "STATIC_URL": settings.STATIC_URL}
    ctx.update(kwargs.get("context", {}))
    subject = "[%s] %s" % (
        current_site.name,
        render_to_string(
            "symposion/emails/%s/subject.txt" % kind, ctx
        ).strip(),
    )

    message_html = render_to_string(
        "symposion/emails/%s/message.html" % kind, ctx
    )
    message_plaintext = strip_tags(message_html)

    from_email = settings.DEFAULT_FROM_EMAIL

    email = EmailMultiAlternatives(
        subject, message_plaintext, from_email, to, cc=cc
    )
    email.attach_alternative(message_html, "text/html")
    email.send() 
开发者ID:pydata,项目名称:conf_site,代码行数:27,代码来源:mail.py

示例11: relative_static_url

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def relative_static_url(self):
        url = settings.STATIC_URL
        rewrite_on = False

        try:
            if settings.REWRITE_STATIC_URLS is True:
                rewrite_on = True
                try:
                    multitenant_relative_url = settings.MULTITENANT_RELATIVE_STATIC_ROOT
                except AttributeError:
                    # MULTITENANT_RELATIVE_STATIC_ROOT is an optional setting. Use the default of just appending
                    # the tenant schema_name to STATIC_ROOT if no configuration value is provided
                    multitenant_relative_url = "%s"

                url = "/" + "/".join(s.strip("/") for s in [url, multitenant_relative_url]) + "/"

        except AttributeError:
            # REWRITE_STATIC_URLS not set - ignore
            pass

        return rewrite_on, url 
开发者ID:django-tenants,项目名称:django-tenants,代码行数:23,代码来源:storage.py

示例12: editor_js

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def editor_js():
    # Add extra JS files to the admin
    js_files = [
        'js/hallo-custom.js',
    ]
    js_includes = format_html_join(
        '\n', '<script src="{0}{1}"></script>',
        ((settings.STATIC_URL, filename) for filename in js_files)
    )

    return js_includes + format_html(
        """
        <script>
            registerHalloPlugin('blockquotebutton');
            registerHalloPlugin('blockquotebuttonwithclass');
        </script>
        """
    ) 
开发者ID:chrisdev,项目名称:wagtail-cookiecutter-foundation,代码行数:20,代码来源:wagtail_hooks.py

示例13: __call__

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def __call__(self, request):
        if request.user.is_authenticated:
            profile = request.profile = request.user.profile
            logout_path = reverse('auth_logout')
            login_2fa_path = reverse('login_2fa')
            webauthn_path = reverse('webauthn_assert')
            change_password_path = reverse('password_change')
            change_password_done_path = reverse('password_change_done')
            has_2fa = profile.is_totp_enabled or profile.is_webauthn_enabled
            if (has_2fa and not request.session.get('2fa_passed', False) and
                    request.path not in (login_2fa_path, logout_path, webauthn_path) and
                    not request.path.startswith(settings.STATIC_URL)):
                return HttpResponseRedirect(login_2fa_path + '?next=' + urlquote(request.get_full_path()))
            elif (request.session.get('password_pwned', False) and
                    request.path not in (change_password_path, change_password_done_path,
                                         login_2fa_path, logout_path) and
                    not request.path.startswith(settings.STATIC_URL)):
                return HttpResponseRedirect(change_password_path + '?next=' + urlquote(request.get_full_path()))
        else:
            request.profile = None
        return self.get_response(request) 
开发者ID:DMOJ,项目名称:online-judge,代码行数:23,代码来源:middleware.py

示例14: do_static

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def do_static(parser, token):
    """
    Joins the given path with the STATIC_URL setting.

    Usage::

        {% static path [as varname] %}

    Examples::

        {% static "myapp/css/base.css" %}
        {% static variable_with_path %}
        {% static "myapp/css/base.css" as admin_base_css %}
        {% static variable_with_path as varname %}
    """
    return StaticNode.handle_token(parser, token) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:18,代码来源:static.py

示例15: update_files_dictionary

# 需要导入模块: from django.conf import settings [as 别名]
# 或者: from django.conf.settings import STATIC_URL [as 别名]
def update_files_dictionary(self, *args):
        super(SPAMiddleware, self).update_files_dictionary(*args)
        index_page_suffix = '/' + self.index_name
        index_name_length = len(self.index_name)
        static_prefix_length = len(settings.STATIC_URL) - 1
        directory_indexes = {}
        for url, static_file in self.files.items():
            if url.endswith(index_page_suffix):
                # For each index file found, add a corresponding URL->content
                # mapping for the file's parent directory,
                # so that the index page is served for
                # the bare directory URL ending in '/'.
                parent_directory_url = url[:-index_name_length]
                directory_indexes[parent_directory_url] = static_file
                # remember the root page for any other unrecognised files
                # to be frontend-routed
                self.spa_root = static_file
            else:
                # also serve static files on /
                # e.g. when /my/file.png is requested, serve /static/my/file.png
                directory_indexes[url[static_prefix_length:]] = static_file
        self.files.update(directory_indexes) 
开发者ID:metakermit,项目名称:django-spa,代码行数:24,代码来源:middleware.py


注:本文中的django.conf.settings.STATIC_URL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。