hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
bef3e3f5ca977935d38bae403cfabb2e78d3554fc950484c2395b8b37582a444 | from django.db import connection
from django.db.models import CharField
from django.db.models.functions import MD5
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import Author
class MD5Tests(TestCase):
@classmethod
def setUpTestData(cls):
Author.objects.b... |
a353a061c3b66e8000cc392ac75409422b624a54b9887c777f0899f30f3584f0 | from django.db import connection
from django.db.models import CharField, Value
from django.db.models.functions import Length, LPad, RPad
from django.test import TestCase
from ..models import Author
class PadTests(TestCase):
def test_pad(self):
Author.objects.create(name='John', alias='j')
none_va... |
cfc48ae50103532ed21091f0db7c14584325928fcd14ec05b68b0e6a5f938387 | from datetime import datetime, timedelta
from django.db.models.functions import Now
from django.test import TestCase
from django.utils import timezone
from ..models import Article
lorem_ipsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore m... |
d13338f8166ef43653495c8df090caba594c66a2ccab2efffaa1172a177f7064 | from datetime import datetime, timedelta, timezone as datetime_timezone
import pytz
from django.conf import settings
from django.db.models import (
DateField, DateTimeField, F, IntegerField, Max, OuterRef, Subquery,
TimeField,
)
from django.db.models.functions import (
Extract, ExtractDay, ExtractHour, Ex... |
079f12b313de243809e5af4fb5ba0c426ec0a2e37bfbe59b372d9768fa64e685 | from django.db.models import TextField
from django.db.models.functions import Coalesce, Lower
from django.test import TestCase
from django.utils import timezone
from ..models import Article, Author
lorem_ipsum = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut l... |
0dc619420ed6872f3fb14b8ee0846db1d64ecdbceeb5472d4487a29b5ebadcb7 | import datetime
import decimal
import unittest
from django.db import connection, models
from django.db.models import Avg
from django.db.models.expressions import Value
from django.db.models.functions import Cast
from django.test import (
TestCase, ignore_warnings, override_settings, skipUnlessDBFeature,
)
from ..... |
0e67b572304c17ea90b6a7ab164a17142186f860d68d74142c72cc1f8dd2862e | from datetime import datetime, timedelta
from decimal import Decimal
from unittest import skipIf, skipUnless
from django.db import connection
from django.db.models.expressions import RawSQL
from django.db.models.functions import Coalesce, Greatest
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
... |
663725137f96e34bf4f4fe76ab3e56029680aaa579295a705bd21b20c310f0ee | from unittest import skipUnless
from django.db import connection
from django.db.models import Value
from django.db.models.functions import NullIf
from django.test import TestCase
from ..models import Author
class NullIfTests(TestCase):
@classmethod
def setUpTestData(cls):
Author.objects.create(name... |
37dffde62a4fbcc63482d23e3e20f0684b5daa12b77ba5ac82a93ee99322a7ff | from datetime import datetime, timedelta
from decimal import Decimal
from unittest import skipIf, skipUnless
from django.db import connection
from django.db.models.expressions import RawSQL
from django.db.models.functions import Coalesce, Least
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
fro... |
71590fdf9d74c62e757eeed26c107ecc0fbd5c98b8918b992270eb05d924203d | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Sqrt
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class SqrtTests(TestCase):
def test_null(self)... |
2584387656580ec211275206fddd20a60c042e0b5b47dc4d8ea5498aca42e932 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Ceil
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class CeilTests(TestCase):
def test_null(self)... |
5111fcad13390eb26d66fafe0909044da07166970ebc7efc4f4536f4d18a9eb7 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import ATan
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class ATanTests(TestCase):
def test_null(self)... |
408e27623c8e50936ab0fa2e0947ae1ba2d5096044007a289423d6debdfcab1e | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Floor
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class FloorTests(TestCase):
def test_null(sel... |
032ea185c86781cb4b24811aef296761e459bd9b734e3621fe2cf2cef24edeb1 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import ACos
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class ACosTests(TestCase):
def test_null(self)... |
e976a3c1b29ea823ccc8ed1c59df2de0c1f8804109390f3c19589765b1f9526d | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Cos
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class CosTests(TestCase):
def test_null(self):
... |
dff6b86d563b259ccf540bacdef74a045d8a9a6d920d7894125655b5c8b4282e | from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Round
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class RoundTests(TestCase):
def test_null(self):
... |
f946bab65c15e9b46d0d0424fd6eb2b6603b985c70f5deb4ae41b2784a08ac19 | from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Abs
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class AbsTests(TestCase):
def test_null(self):
Inte... |
f2042ca0b1198739a6d323dee5ab7512a36fade8ecf6a0b3ede510574e12550b | from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Sign
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class SignTests(TestCase):
def test_null(self):
In... |
c0c4a110407f1ee64492d9af6d0c8af4a9cda0c3977c882904606a6a056a56fc | import math
from decimal import Decimal
from django.db.models.functions import Log
from django.test import TestCase
from ..models import DecimalModel, FloatModel, IntegerModel
class LogTests(TestCase):
def test_null(self):
IntegerModel.objects.create(big=100)
obj = IntegerModel.objects.annotate... |
510b210649918133f1e7c9b11fdadf4c07d61491578cc8072645b050944255b7 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Cot
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class CotTests(TestCase):
def test_null(self):
... |
0f65fa021806bf7e232a1dafdedf6b150326e6e393f0220344631ac0acdd414a | import math
from decimal import Decimal
from django.db.models.functions import ATan2
from django.test import TestCase
from ..models import DecimalModel, FloatModel, IntegerModel
class ATan2Tests(TestCase):
def test_null(self):
IntegerModel.objects.create(big=100)
obj = IntegerModel.objects.anno... |
d9c89abe82718f6122948ddf48cd306afe6df7725204c1e728ed38590f387df3 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Degrees
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class DegreesTests(TestCase):
def test_null... |
980cc092cab2cb691df4ea8405322d2bb0b2c4f9998b5da78205297006071812 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import ASin
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class ASinTests(TestCase):
def test_null(self)... |
6e74a00d0cd7e9a842867a71110b84f81ba684e9c215e454a0554e55e640fc1f | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Tan
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class TanTests(TestCase):
def test_null(self):
... |
257c0adf8ea5569d5e2c4afc3b67634b45e17ba62f62888d39197c69ef71de71 | import math
from decimal import Decimal
from django.db.models.functions import Mod
from django.test import TestCase
from ..models import DecimalModel, FloatModel, IntegerModel
class ModTests(TestCase):
def test_null(self):
IntegerModel.objects.create(big=100)
obj = IntegerModel.objects.annotate... |
e250cb39d3902553d086a0ab5ba6a74b18b547321f226a7d843b0e0bf3e2dc50 | from decimal import Decimal
from django.db.models.functions import Power
from django.test import TestCase
from ..models import DecimalModel, FloatModel, IntegerModel
class PowerTests(TestCase):
def test_null(self):
IntegerModel.objects.create(big=100)
obj = IntegerModel.objects.annotate(
... |
d4ae0acd11cedada2f4299331bd59098bd80232f3acb9a45b06699a7a641f045 | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Radians
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class RadiansTests(TestCase):
def test_null... |
5cc1ef865b853cc54de9811f847ad6a2a80477a49e90c7125e0bf1c1aff3222d | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Sin
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class SinTests(TestCase):
def test_null(self):
... |
a15f1d865d959ecf587e448bcf7f09b7ea7468dec6589683e525374ab143f83b | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Exp
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class ExpTests(TestCase):
def test_null(self):
... |
1e78dee13e1e53c0cd3e20dcb5439806623d0d9ac8bbe00cf52c80f814487e02 | import math
from django.db.models.functions import Pi
from django.test import TestCase
from ..models import FloatModel
class PiTests(TestCase):
def test(self):
FloatModel.objects.create(f1=2.5, f2=15.9)
obj = FloatModel.objects.annotate(pi=Pi()).first()
self.assertIsInstance(obj.pi, flo... |
54a201bb783feb35d344917c59ef8a0f2f2b45711147e4d06370a94fb91bcf9f | import math
from decimal import Decimal
from django.db.models import DecimalField
from django.db.models.functions import Ln
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import DecimalModel, FloatModel, IntegerModel
class LnTests(TestCase):
def test_null(self):
... |
45aae6eebe9486f09b9f7dfd1b2b769df9b20f31d1a859ac18f9426aa3c26478 | import os
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.utils import translation
@override_settings(
USE_I18N=True,
LOCALE_PATHS=[
os.path.join(os.path.dirname(__file__), 'locale'),
],
LANGUAGE_CODE='en',
LANGUAG... |
0c4647fef1969e19e026bdb236f851b6c2d6084ab86f15bcd5b7d5e3821ed24d | from django.urls import path
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
path('foo/', view, name='not-prefixed-included-url'),
]
|
663c5cf90f9de4d48fee1d733944ac3fca6f68cdf30e796720f80464b6c02f79 | from django.conf.urls.i18n import i18n_patterns
from django.urls import include, re_path
from django.utils.translation import gettext_lazy as _
urlpatterns = i18n_patterns(
re_path(_(r'^account/'), include('i18n.patterns.urls.wrong_namespace', namespace='account')),
)
|
7d84a51c1cb6c7d16c20f412b80a155e43ebadc8df501c323b3de69b503504b9 | from django.conf.urls.i18n import i18n_patterns
from django.urls import include, path, re_path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
path('not-prefixed/', view, name='not-prefixed... |
926d3d3d710ee26e204e975a7aaa03bff4f4cb29b2004bb1d9fe78ea13bcf27f | from django.urls import re_path
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
re_path('^nl/foo/', view, name='not-translated'),
]
|
7a6ac21ab984114b3b5930c5a1b45e8c929084243190a336bd5f816aa8897830 | from django.conf.urls.i18n import i18n_patterns
from django.urls import re_path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
app_name = 'account'
urlpatterns = i18n_patterns(
re_path(_(r'^register/$'), ... |
e1c6c14b7fcd773ad5d21fc1550a8aae27df99014424ed3e22152470d5a00274 | from django.urls import path, re_path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
app_name = 'account'
urlpatterns = [
re_path(_(r'^register/$'), view, name='register'),
re_path(_(r'^register-witho... |
e625fe22329af0c06b8ea6fe93315c005bf5ad04c72e8839a785231aa12a5651 | from django.conf.urls.i18n import i18n_patterns
from django.urls import path
from django.views.generic import TemplateView
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = i18n_patterns(
path('prefixed/', view, name='prefixed'),
)
|
f05f2c413b41ad6781a201f5c61798fc5cf3681222b1dbb73619c457f799f505 | """
Sphinx plugins for Django documentation.
"""
import json
import os
import re
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives import CodeBlock
fr... |
492636caa5beaadb4b49181fd84d24b05326a6b7cbd5c2456ff97d9988eba6e5 | import os
import sys
from distutils.sysconfig import get_python_lib
from setuptools import find_packages, setup
CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 5)
# This check and everything above must remain compatible with Python 2.7.
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write("""
======... |
69e4521174527d578f146e17e5ba4f7a4e70b49dd6c96933ca0d83810e1724f8 | #!/usr/bin/env python
import argparse
import atexit
import copy
import os
import shutil
import socket
import subprocess
import sys
import tempfile
import warnings
import django
from django.apps import apps
from django.conf import settings
from django.db import connection, connections
from django.test import TestCase, ... |
d0c8aedbc25ac531881f2a7de1105d419a463068bd7f9467122a9338c8bbac0d | # Django documentation build configuration file, created by
# sphinx-quickstart on Thu Mar 27 09:06:53 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't picklable (module imports are okay... |
1e98482108b1b0fdee516a845db53ec2091049e2c4db7efdb346d63a995e49b8 | import sys
import unittest
from contextlib import contextmanager
from django.test import LiveServerTestCase, tag
from django.utils.decorators import classproperty
from django.utils.module_loading import import_string
from django.utils.text import capfirst
class SeleniumTestCaseBase(type(LiveServerTestCase)):
# L... |
1ca63cb1463db8c726820f5fa5a7c25eee504f5eaa494e59476f8c91276f1eb7 | import ctypes
import itertools
import logging
import multiprocessing
import os
import pickle
import textwrap
import unittest
from importlib import import_module
from io import StringIO
from django.core.management import call_command
from django.db import connections
from django.test import SimpleTestCase, TestCase
fro... |
8820e26a234b28907f7dc64b0e4e2ceea945834779f124a3eb63865cdf85d16f | import json
import mimetypes
import os
import re
import sys
from copy import copy
from functools import partial
from http import HTTPStatus
from importlib import import_module
from io import BytesIO
from urllib.parse import unquote_to_bytes, urljoin, urlparse, urlsplit
from django.conf import settings
from django.core... |
9843f306fb99d9876d41c1d5a617b9d438698e36e9c47bc655cafd88cdc51356 | import difflib
import json
import posixpath
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy
from difflib import get_close_matches
from functools import wraps
from unittest.util import safe_repr
from urllib.parse impo... |
c4018839bff0d38e4a7cf2ec0013af7103cd65b61765f29a1a5ec2e2d8522704 | """Compare two HTML documents."""
import re
from html.parser import HTMLParser
WHITESPACE = re.compile(r'\s+')
def normalize_whitespace(string):
return WHITESPACE.sub(' ', string)
class Element:
def __init__(self, name, attributes):
self.name = name
self.attributes = sorted(attributes)
... |
d37dbb723c69c35a0a7bd1f977c5dfedc76d5c4e1d97d5eba432f9e3195daf69 | import collections
import logging
import re
import sys
import time
import warnings
from contextlib import contextmanager
from functools import wraps
from io import StringIO
from itertools import chain
from types import SimpleNamespace
from unittest import TestCase, skipIf, skipUnless
from xml.dom.minidom import Node, p... |
f27f6c64f29e7d693b8b9a583d8701ba07bd37299dba4c2947680bb0936f1e57 | import functools
import sys
import threading
import warnings
from collections import Counter, OrderedDict, defaultdict
from functools import partial
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from .config import AppConfig
class Apps:
"""
A registry that stores the configura... |
9274581891ef44402640912912de61b2e9192684c67f33fcd012722d059421f9 | from urllib.parse import quote
from django.http import (
HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound,
HttpResponseServerError,
)
from django.template import Context, Engine, TemplateDoesNotExist, loader
from django.views.decorators.csrf import requires_csrf_token
ERROR_404_TEMPLATE_NAM... |
f0e4d331827f23c5e80d08c2ac6fc87ca6e2db604272096a60818faf01b43cfa | import functools
import re
import sys
import types
from pathlib import Path
from django.conf import settings
from django.http import HttpResponse, HttpResponseNotFound
from django.template import Context, Engine, TemplateDoesNotExist
from django.template.defaultfilters import pprint
from django.urls import Resolver404... |
ec43c9e0632a7823fe35b30ed34663642d0fea2d2e0d5510841b48174ce90554 | """
Settings and configuration for Django.
Read values from the module specified by the DJANGO_SETTINGS_MODULE environment
variable, and then from django.conf.global_settings; see the global_settings.py
for a list of all possible variables.
"""
import importlib
import os
import time
import traceback
import warnings
f... |
ce4ddfe498d5763714d9f0292e59d3834f85305adca40018b4a3d92b79b6db34 | """
Default Django settings. Override these with settings in the module pointed to
by the DJANGO_SETTINGS_MODULE environment variable.
"""
# This is defined here as a do-nothing function because we can't import
# django.utils.translation -- that module depends on the settings.
def gettext_noop(s):
return s
####... |
b216e6e2197d1199e41926ab53c9023427ef8b77d1cfecb8229327ddc2e7fe3d | "Functions that help with dynamically creating decorators for views."
# For backwards compatibility in Django 2.0.
from contextlib import ContextDecorator # noqa
from functools import WRAPPER_ASSIGNMENTS, partial, update_wrapper, wraps
class classonlymethod(classmethod):
def __get__(self, instance, cls=None):
... |
9168e49ec0c41a0addda587aa96eb71cd779ee52483042ec5e375e1d98c7af2e | import functools
import itertools
import logging
import os
import pathlib
import signal
import subprocess
import sys
import threading
import time
import traceback
from collections import defaultdict
from pathlib import Path
from types import ModuleType
from zipimport import zipimporter
from django.apps import apps
fro... |
d9330ad516093543593b729949ae2a12d646e77ce9f35345d7a70370da94ffe3 | import html.entities
import re
import unicodedata
from gzip import GzipFile
from io import BytesIO
from django.utils.functional import SimpleLazyObject, keep_lazy_text, lazy
from django.utils.translation import gettext as _, gettext_lazy, pgettext
@keep_lazy_text
def capfirst(x):
"""Capitalize the first letter o... |
ef81653082a122432c65bf512fd459e04a6d786855a310deb29504aa07c33dac | """
Utilities for XML generation/parsing.
"""
import re
from collections import OrderedDict
from xml.sax.saxutils import XMLGenerator
class UnserializableContentError(ValueError):
pass
class SimplerXMLGenerator(XMLGenerator):
def addQuickElement(self, name, contents=None, attrs=None):
"Convenience ... |
4179d1924b0ab6865133c694020f8ad8eda9620de030377bc789ec8ca714054e | from decimal import Decimal
from django.conf import settings
from django.utils.safestring import mark_safe
def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
force_grouping=False, use_l10n=None):
"""
Get a number (as a number or string), and return it as a string,
u... |
ee10db393538a2192218ce6526e64dbe5f75a655d1d79493f560977169bf6dda | import codecs
import datetime
import locale
from decimal import Decimal
from urllib.parse import quote
from django.utils import six
from django.utils.functional import Promise
class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args):
self.obj = obj
super().__init__(*args... |
590342ff71de3945d5e0a2c40f3300740e4ac410b606a2e7538d22db38953837 | import copy
from collections import OrderedDict
from collections.abc import Mapping
class OrderedSet:
"""
A set which keeps the ordering of the inserted items.
Currently backs onto OrderedDict.
"""
def __init__(self, iterable=None):
self.dict = OrderedDict.fromkeys(iterable or ())
de... |
edac52f8da1abb4796d72bc57b8b5e0b972cefbe1e52aadc4925a37fed6d9a5e | import copy
import os
from importlib import import_module
from importlib.util import find_spec as importlib_find
def import_string(dotted_path):
"""
Import a dotted module path and return the attribute/class designated by the
last name in the path. Raise ImportError if the import failed.
"""
try:
... |
a144411117ba593129d19200e6155a8d4ad26579665dcbcf1ecb615cf6be30d6 | """HTML utilities suitable for global use."""
import json
import re
from html.parser import HTMLParser
from urllib.parse import (
parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
)
from django.utils.functional import Promise, keep_lazy, keep_lazy_text
from django.utils.http import RFC3986_GENDELIMS, RF... |
079c82651264660ddc1ef7e41e11f005f106ea1a0f2f9ec9ddf5441d1173494c | """
Functions for working with "safe strings": strings that can be displayed safely
without further escaping in HTML. Marking something as a "safe string" means
that the producer of the string has already turned characters that should not
be interpreted by the HTML engine (e.g. '<') into the appropriate entities.
"""
... |
495f01e3d2ca25660c4cb3d24ee76a9b841d44d65cdb2a2c7ca1c008b7efce18 | import copy
import itertools
import operator
from functools import total_ordering, wraps
from django.utils.version import PY36, get_docs_version
# You can't trivially replace this with `functools.partial` because this binds
# to classes and returns bound instances, whereas functools.partial (on
# CPython) is a type ... |
6a3d81de80e8672133a9bf12094ed5be3d8e85af6bf1d099f992aef42dceb998 | import base64
import calendar
import datetime
import re
import unicodedata
from binascii import Error as BinasciiError
from email.utils import formatdate
from urllib.parse import (
ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams, quote,
quote_plus, scheme_chars, unquote, unquote_plus,
url... |
3bc4dd47b7f45595092ed109f3046e014e0edf4683b7b8d10493ded2e271e855 | import os
import tempfile
from os.path import abspath, dirname, join, normcase, sep
from django.core.exceptions import SuspiciousFileOperation
# For backwards-compatibility in Django 2.0
abspathu = abspath
def upath(path):
"""Always return a unicode path (did something for Python 2)."""
return path
def np... |
807e0fb4f3efda4a10c45eb3e433c80354522e99f4ef81bc4645c079c7baa303 | """
This is the Django template system.
How it works:
The Lexer.tokenize() method converts a template string (i.e., a string
containing markup with custom template tags) to tokens, which can be either
plain text (TokenType.TEXT), variables (TokenType.VAR), or block statements
(TokenType.BLOCK).
The Parser() class ta... |
3c90579039afdc0221e96ba06f215c50abb4d5728d0f1938dc12944532e123b8 | import functools
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from .base import Context, Template
from .context import _builtin_context_processors
from .exceptions import TemplateDoesNotExist
from .lib... |
0f02baa0207aa2f3fdfbf27cb5ff9cf9cf5cecb9c817635edb7b0242842e1013 | """Default variable filters."""
import random as random_module
import re
import types
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from operator import itemgetter
from pprint import pformat
from urllib.parse import quote
from django.utils import formats
from django.... |
8fcb8bd780eed456a263eb4af3b6044116f532c612444aa92e35b1910cda5553 | import re
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.mail import mail_managers
from django.http import HttpResponsePermanentRedirect
from django.urls import is_valid_path
from django.utils.deprecation import MiddlewareMixin
fr... |
02686cbef25cc1c662e960ef7dfb09c8ce42afb3e8fd2d01cbcd877d5376aa45 | """
Cross Site Request Forgery Middleware.
This module provides a middleware that implements protection
against request forgeries from other sites.
"""
import logging
import re
import string
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import DisallowedHost, Improperl... |
c5737e193aca1b97a7b0256170fcfc6993ede5831b275c511de3c5473f07e142 | from contextlib import ContextDecorator, contextmanager
from django.db import (
DEFAULT_DB_ALIAS, DatabaseError, Error, ProgrammingError, connections,
)
class TransactionManagementError(ProgrammingError):
"""Transaction management is used improperly."""
pass
def get_connection(using=None):
"""
... |
bcd6f0cd1de5f242cc768d7eabdda2eb5f1516b584129fb188d90765fefe2759 | """
This module converts requested URLs to callback view functions.
URLResolver is the main class here. Its resolve() method takes a URL (as
a string) and returns a ResolverMatch object which provides access to all
attributes of the resolved URL match.
"""
import functools
import inspect
import re
import threading
fro... |
3840ca8335d38b102a0498bc43e247a2620c458e1315141299e7fc034245f3eb | """
Helper functions for creating Form classes from Django models
and database field objects.
"""
from collections import OrderedDict
from itertools import chain
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
)
from django.forms.fields import ChoiceField,... |
47dc34328422b4ac027d7ca56c05363b8271cc48fa30a02dfda7710580dfc9f4 | from django.core.exceptions import ValidationError
from django.forms import Form
from django.forms.fields import BooleanField, IntegerField
from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput
from django.utils.functional import cached_property
from django.utils.html import html_safe
fr... |
7f2fdcc42900a18db533c7b7b02b7cf96f49d422c4f46454bb8d294d9395a4ad | """
HTML Widget classes
"""
import copy
import datetime
import re
import warnings
from itertools import chain
from django.conf import settings
from django.forms.utils import to_current_timezone
from django.templatetags.static import static
from django.utils import datetime_safe, formats
from django.utils.dates import... |
3a84af0c8ced58c89fa1a1b0b4c603af7c6b15623dbf40b0f507bd79f39c73de | import datetime
import json
import mimetypes
import os
import re
import sys
import time
from email.header import Header
from http.client import responses
from urllib.parse import quote, urlparse
from django.conf import settings
from django.core import signals, signing
from django.core.exceptions import DisallowedRedir... |
3efc84a4c995a046c8ad8cad1d5abac328ad655696f587b084f3f06a10500fff | import copy
import re
from io import BytesIO
from itertools import chain
from urllib.parse import quote, urlencode, urljoin, urlsplit
from django.conf import settings
from django.core import signing
from django.core.exceptions import (
DisallowedHost, ImproperlyConfigured, RequestDataTooBig,
)
from django.core.fil... |
04e6c7833dd8c2135a8c541779f36fb7dc5c1826f966e6f5217c16f3ecfa9d5d | """
LANG_INFO is a dictionary structure to provide meta information about languages.
About name_local: capitalize it as if your language name was appearing
inside a sentence in your language.
The 'fallback' key can be used to specify a special fallback logic which doesn't
follow the traditional 'fr-ca' -> 'fr' fallbac... |
2f6bb4ab06e7044dc9ab88cf9b8afdcc00e659d58e5e0a396faa95904bb594c2 | """Translation helper functions."""
import functools
import gettext as gettext_module
import os
import re
import sys
import warnings
from collections import OrderedDict
from threading import local
from django.apps import apps
from django.conf import settings
from django.conf.locale import LANG_INFO
from django.core.ex... |
7634360f6b63f7f402ac759476a34577f15ac9f58c32bca6a13e5cddbe905ad7 | """
Internationalization support.
"""
import re
from contextlib import ContextDecorator
from django.utils.autoreload import autoreload_started, file_changed
from django.utils.functional import lazy
__all__ = [
'activate', 'deactivate', 'override', 'deactivate_all',
'get_language', 'get_language_from_request',... |
313c2ae9b8e30182c8ad11a152d60673fc2aac67f33f48852be1ffafc83d4042 | from django.apps.registry import apps as global_apps
from django.db import migrations, router
from .exceptions import InvalidMigrationPlan
from .loader import MigrationLoader
from .recorder import MigrationRecorder
from .state import ProjectState
class MigrationExecutor:
"""
End-to-end migration execution - ... |
1e87aeab62005ac0c6dccde987deaf9ae9fa7f35d289fb8599457447518c2a43 | import copy
from collections import OrderedDict
from contextlib import contextmanager
from django.apps import AppConfig
from django.apps.registry import Apps, apps as global_apps
from django.conf import settings
from django.db import models
from django.db.models.fields.proxy import OrderWrt
from django.db.models.field... |
06d21d93b028d48c35ef4027279a1b8a4671537f1bf8d49cafc23fee7d7bd0bc | import pkgutil
import sys
from importlib import import_module, reload
from django.apps import apps
from django.conf import settings
from django.db.migrations.graph import MigrationGraph
from django.db.migrations.recorder import MigrationRecorder
from .exceptions import (
AmbiguityError, BadMigrationError, Inconsi... |
a64d476f01b1d182931d7981fccde5c2a27de94e22b81fc2b2ee14572ffda994 | import os
import re
from importlib import import_module
from django import get_version
from django.apps import apps
# SettingsReference imported for backwards compatibility in Django 2.2.
from django.conf import SettingsReference # NOQA
from django.db import migrations
from django.db.migrations.loader import Migratio... |
d266ab2180eef5a4fddaacbbbdc7e4d9e3f7b2da1406142a65e4b18480884d4a | import functools
import re
from itertools import chain
from django.conf import settings
from django.db import models
from django.db.migrations import operations
from django.db.migrations.migration import Migration
from django.db.migrations.operations.models import AlterModelOptions
from django.db.migrations.optimizer ... |
dc33d47afb520d2b80f564ceca5c9cfbcced129f0318b69e9d7d29bb0578f343 | import builtins
import collections.abc
import datetime
import decimal
import enum
import functools
import math
import re
import types
import uuid
from collections import OrderedDict
from django.conf import SettingsReference
from django.db import models
from django.db.migrations.operations.base import Operation
from dj... |
1aa401c76018749ed1769af29da7a33157c4d155af5b846b47d40f15bd460882 | """
Classes to represent the definitions of aggregate functions.
"""
from django.core.exceptions import FieldError
from django.db.models.expressions import Case, Func, Star, When
from django.db.models.fields import IntegerField
from django.db.models.functions.mixins import (
FixDurationInputMixin, NumericOutputFiel... |
eb2d4546fea37272974d26b4a3cae2417afdd479339291a2406974530ff3b7e7 | """
The main QuerySet implementation. This provides the public API for the ORM.
"""
import copy
import operator
import warnings
from collections import OrderedDict, namedtuple
from functools import lru_cache
from itertools import chain
from django.conf import settings
from django.core import exceptions
from django.db... |
a2df96ef941d97407d70f77b0f6afdef12560c8cdcd7e74d45d79f7d86701cf8 | import copy
import inspect
from bisect import bisect
from collections import OrderedDict, defaultdict
from django.apps import apps
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
from django.db import connections
from django.db.models import Manager
from djan... |
dc77290eed8039e52186e7ad28da5c0aa8319739280f42488386f5635fdf2ce6 | import copy
import inspect
import warnings
from functools import partialmethod
from itertools import chain
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldDoesNotExist, FieldError, MultipleObjectsReturned,
... |
cfaf46ae42683033a779827deaaf109e226c7de4693e2e8e796e497cff291400 | """
Various data structures used in query construction.
Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into
circular import difficulties.
"""
import copy
import functools
import inspect
from collections import namedtu... |
5ef594ffdc2bd0bcdcc5776eadc2f62baa2ad7130a7c960333fcceae17f57d8a | import copy
import datetime
import inspect
from decimal import Decimal
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import connection
from django.db.models import fields
from django.db.models.query_utils import Q
from django.utils.deconstruct import deconstructible
from django.utils.fun... |
88a016db6e03fcd64b4dd6cb087c2e78c3f0f4dc17969680f7caf3f31fac350c | from collections import Counter, OrderedDict
from operator import attrgetter
from django.db import IntegrityError, connections, transaction
from django.db.models import signals, sql
class ProtectedError(IntegrityError):
def __init__(self, msg, protected_objects):
self.protected_objects = protected_object... |
9d3697c2a26d49f4a335e64b6280e8184d0a6914013074596080d95db6df5c58 | import datetime
import decimal
import functools
import hashlib
import logging
from time import time
from django.conf import settings
from django.db.utils import NotSupportedError
from django.utils.timezone import utc
logger = logging.getLogger('django.db.backends')
class CursorWrapper:
def __init__(self, cursor... |
13449dc23401251971fc8c9d038ec8868eebdf57ab2eeb08d67d75107c568e7c | from collections import namedtuple
from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT
def is_referenced_by_foreign_key(state, model_name_lower, field, field_name):
for state_app_label, state_model in state.models:
for _, f in state.models[state_app_label, state_model].fields:
... |
2fe13148e47b852a41f3f92e65affb0db17eed7a00ffc7d50a84d35e151d8532 | import collections.abc
import copy
import datetime
import decimal
import operator
import uuid
import warnings
from base64 import b64decode, b64encode
from functools import partialmethod, total_ordering
from django import forms
from django.apps import apps
from django.conf import settings
from django.core import checks... |
b673e9f51e92a741cd736f8e890af511607bec30e2ca130f520f9abd2c4cea0e | import functools
import inspect
from functools import partial
from django import forms
from django.apps import apps
from django.conf import SettingsReference
from django.core import checks, exceptions
from django.db import connection, router
from django.db.backends import utils
from django.db.models import Q
from djan... |
c551eb12bfc32aa29ad00c0d47e93fd06c4133ba7d8d621ca9aa3ef87c2e9254 | """
Accessors for related objects.
When a field defines a relation between two models, each model class provides
an attribute to access related instances of the other model class (unless the
reverse accessor has been disabled with related_name='+').
Accessors are implemented as descriptors in order to customize acces... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.