當前位置: 首頁>>代碼示例>>Python>>正文


Python settings.DEBUG屬性代碼示例

本文整理匯總了Python中django.conf.settings.DEBUG屬性的典型用法代碼示例。如果您正苦於以下問題:Python settings.DEBUG屬性的具體用法?Python settings.DEBUG怎麽用?Python settings.DEBUG使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在django.conf.settings的用法示例。


在下文中一共展示了settings.DEBUG屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: enqueue

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def enqueue(self) -> None:
        for index, external_url in enumerate(self.urls):
            if index == self.musiq.base.settings.basic.max_playlist_items:
                break
            # request every url in the playlist as their own url
            song_provider = SongProvider.create(self.musiq, external_url=external_url)

            try:
                song_provider.request("", archive=False, manually_requested=False)
            except ProviderError:
                continue

            if settings.DEBUG:
                # the sqlite database has problems if songs are pushed very fast
                # while a new song is taken from the queue. Add a delay to mitigate.
                time.sleep(1) 
開發者ID:raveberry,項目名稱:raveberry,代碼行數:18,代碼來源:music_provider.py

示例2: index

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [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

示例3: _pre_setup

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def _pre_setup(self):
        """Disable transaction methods, and clear some globals."""
        # Repeat stuff from TransactionTestCase, because I'm not calling its
        # _pre_setup, because that would load fixtures again.
        cache.cache.clear()
        settings.TEMPLATE_DEBUG = settings.DEBUG = False


        self.client = self.client_class()
        #self._fixture_setup()
        self._urlconf_setup()
        mail.outbox = []

        # Clear site cache in case somebody's mutated Site objects and then
        # cached the mutated stuff:
        from django.contrib.sites.models import Site
        Site.objects.clear_cache() 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:19,代碼來源:testcase.py

示例4: csp_report_view

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def csp_report_view(request):
    global generic_related
    report_json = request.body.decode('utf8')
    report = json.loads(report_json)
    resp = HttpResponse()

    if ('script-sample' in report['csp-report']
            and 'var t=0,e=function(t,e){ret' in report['csp-report']['script-sample']) or \
            ('script-sample' in report['csp-report'] and report['csp-report']['script-sample'] == ';undefined'):
        # firefox browser plugin injection?
        return resp

    if generic_related is None:
        generic_related = Unit.objects.get(slug='univ')
    userid = request.user.username if request.user.is_authenticated else '_anon'
    l = LogEntry(userid=userid, description='CSP violation', comment=report_json, related_object=generic_related)
    l.save()

    if settings.DEBUG:
        print(json.dumps(report, indent=2))

    return resp 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:24,代碼來源:csp.py

示例5: validate_url

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def validate_url(request):
    assert request.method == "GET"
    assert request.is_ajax()
    url = request.GET.get('url')
    assert url
    try:
        URLValidator(url)
    except ValidationError:
        raise AssertionError()
    assert 'HTTP_REFERER' in request.META
    toproxy = urlparse(url)
    assert toproxy.hostname
    if settings.DEBUG:
        return url
    referer = urlparse(request.META.get('HTTP_REFERER'))
    assert referer.hostname == request.META.get('SERVER_NAME')
    assert toproxy.hostname != "localhost"
    try:
        # clean this when in python 3.4
        ipaddress = socket.gethostbyname(toproxy.hostname)
    except:
        raise AssertionError()
    assert not ipaddress.startswith('127.')
    assert not ipaddress.startswith('192.168.')
    return url 
開發者ID:ideascube,項目名稱:ideascube,代碼行數:27,代碼來源:views.py

示例6: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def render(self, render_type, context):
        """
        Renders the template

        :param render_type: the content type to render
        :param context: context data dictionary
        :return: the rendered content
        """

        assert render_type in self.render_types, 'Invalid Render Type'

        try:
            content = render_to_string('herald/{}/{}.{}'.format(
                render_type,
                self.template_name,
                'txt' if render_type == 'text' else render_type
            ), context)
        except TemplateDoesNotExist:
            content = None

            if settings.DEBUG:
                raise

        return content 
開發者ID:worthwhile,項目名稱:django-herald,代碼行數:26,代碼來源:base.py

示例7: default_urlconf

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def default_urlconf(request):
    "Create an empty URLconf 404 error response."
    t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE)
    c = Context({
        "title": _("Welcome to Django"),
        "heading": _("It worked!"),
        "subheading": _("Congratulations on your first Django-powered page."),
        "instructions": _("Of course, you haven't actually done any work yet. "
            "Next, start your first app by running <code>python manage.py startapp [app_label]</code>."),
        "explanation": _("You're seeing this message because you have <code>DEBUG = True</code> in your "
            "Django settings file and you haven't configured any URLs. Get to work!"),
    })

    return HttpResponse(t.render(c), content_type='text/html')

#
# Templates are embedded in the file so that we know the error handler will
# always work even if the template loader is broken.
# 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:21,代碼來源:debug.py

示例8: process_response

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def process_response(self, request, response):
        """
        Send broken link emails for relevant 404 NOT FOUND responses.
        """
        if response.status_code == 404 and not settings.DEBUG:
            domain = request.get_host()
            path = request.get_full_path()
            referer = force_text(request.META.get('HTTP_REFERER', ''), errors='replace')

            if not self.is_ignorable_request(request, path, domain, referer):
                ua = request.META.get('HTTP_USER_AGENT', '<none>')
                ip = request.META.get('REMOTE_ADDR', '<none>')
                mail_managers(
                    "Broken %slink on %s" % (
                        ('INTERNAL ' if self.is_internal_request(domain, referer) else ''),
                        domain
                    ),
                    "Referrer: %s\nRequested URL: %s\nUser agent: %s\n"
                    "IP address: %s\n" % (referer, path, ua, ip),
                    fail_silently=True)
        return response 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:23,代碼來源:common.py

示例9: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def render(self, context):
        csrf_token = context.get('csrf_token', None)
        if csrf_token:
            if csrf_token == 'NOTPROVIDED':
                return format_html("")
            else:
                return format_html("<input type='hidden' name='csrfmiddlewaretoken' value='{}' />", csrf_token)
        else:
            # It's very probable that the token is missing because of
            # misconfiguration, so we raise a warning
            if settings.DEBUG:
                warnings.warn(
                    "A {% csrf_token %} was used in a template, but the context "
                    "did not provide the value.  This is usually caused by not "
                    "using RequestContext."
                )
            return '' 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:defaulttags.py

示例10: serve

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def serve(request, path, insecure=False, **kwargs):
    """
    Serve static files below a given point in the directory structure or
    from locations inferred from the staticfiles finders.

    To use, put a URL pattern such as::

        from django.contrib.staticfiles import views

        url(r'^(?P<path>.*)$', views.serve)

    in your URLconf.

    It uses the django.views.static.serve() view to serve the found files.
    """
    if not settings.DEBUG and not insecure:
        raise Http404
    normalized_path = posixpath.normpath(unquote(path)).lstrip('/')
    absolute_path = finders.find(normalized_path)
    if not absolute_path:
        if path.endswith('/') or path == '':
            raise Http404("Directory indexes are not allowed here.")
        raise Http404("'%s' could not be found" % path)
    document_root, path = os.path.split(absolute_path)
    return static.serve(request, path, document_root=document_root, **kwargs) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:27,代碼來源:views.py

示例11: process_exception

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def process_exception(self, request, exception):
        # Ignore exception catching if debug mode is on
        if settings.DEBUG:
            return

        # Lets Django handling 404
        if isinstance(exception, Http404):
            return

        template = None
        if isinstance(exception, ProgrammingError):
            template = "errors/programming_error.html"
        elif isinstance(exception, ImportError):
            template = "errors/import_error.html"

        if template:
            return ServerError(request, template_name=template) 
開發者ID:respawner,項目名稱:peering-manager,代碼行數:19,代碼來源:middleware.py

示例12: render

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def render(self, context):
        resolve = lambda arg: arg.resolve(context) if isinstance(arg, FilterExpression) else arg

        prefs_obj = resolve(self.prefs_obj)
        if not isinstance(prefs_obj, tuple):
            if settings.DEBUG:
                raise SiteMessageConfigurationError(
                    '`sitemessage_prefs_table` template tag expects a tuple generated '
                    'by `get_user_preferences_for_ui` but `%s` is given.' % type(prefs_obj))
            return ''  # Silent fall.

        context.push()
        context['sitemessage_user_prefs'] = prefs_obj
        contents = get_template(
            resolve(self.use_template or 'sitemessage/user_prefs_table.html')
        ).render(context.flatten() if _CONTEXT_FLATTEN else context)
        context.pop()

        return contents 
開發者ID:idlesign,項目名稱:django-sitemessage,代碼行數:21,代碼來源:sitemessage.py

示例13: execute_query

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def execute_query(self, request: HttpRequest, data: dict) -> GraphQLResult:
        context_value = self.get_context_for_request(request)
        extensions = self.get_extensions_for_request(request, context_value)

        return graphql_sync(
            cast(GraphQLSchema, self.schema),
            data,
            context_value=context_value,
            root_value=self.root_value,
            validation_rules=self.validation_rules,
            debug=settings.DEBUG,
            introspection=self.introspection,
            logger=self.logger,
            error_formatter=self.error_formatter or format_error,
            extensions=extensions,
            middleware=self.middleware,
        ) 
開發者ID:mirumee,項目名稱:ariadne,代碼行數:19,代碼來源:views.py

示例14: get_full_path_with_slash

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def get_full_path_with_slash(self, request):
        """
        Return the full path of the request with a trailing slash appended.

        Raise a RuntimeError if settings.DEBUG is True and request.method is
        POST, PUT, or PATCH.
        """
        new_path = request.get_full_path(force_append_slash=True)
        if settings.DEBUG and request.method in ('POST', 'PUT', 'PATCH'):
            raise RuntimeError(
                "You called this URL via %(method)s, but the URL doesn't end "
                "in a slash and you have APPEND_SLASH set. Django can't "
                "redirect to the slash URL while maintaining %(method)s data. "
                "Change your form to point to %(url)s (note the trailing "
                "slash), or set APPEND_SLASH=False in your Django settings." % {
                    'method': request.method,
                    'url': request.get_host() + new_path,
                }
            )
        return new_path 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:22,代碼來源:common.py

示例15: process_response

# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import DEBUG [as 別名]
def process_response(self, request, response):
        """Send broken link emails for relevant 404 NOT FOUND responses."""
        if response.status_code == 404 and not settings.DEBUG:
            domain = request.get_host()
            path = request.get_full_path()
            referer = request.META.get('HTTP_REFERER', '')

            if not self.is_ignorable_request(request, path, domain, referer):
                ua = request.META.get('HTTP_USER_AGENT', '<none>')
                ip = request.META.get('REMOTE_ADDR', '<none>')
                mail_managers(
                    "Broken %slink on %s" % (
                        ('INTERNAL ' if self.is_internal_request(domain, referer) else ''),
                        domain
                    ),
                    "Referrer: %s\nRequested URL: %s\nUser agent: %s\n"
                    "IP address: %s\n" % (referer, path, ua, ip),
                    fail_silently=True)
        return response 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:21,代碼來源:common.py


注:本文中的django.conf.settings.DEBUG屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。