當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。