hash
stringlengths
64
64
content
stringlengths
0
1.51M
0f73435012f585600743d3d3ece2d5af4a8f6580afccbe18213570a2eb3ae5a4
from django.contrib.admin import ModelAdmin, TabularInline from django.contrib.admin.helpers import InlineAdminForm from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import Requ...
deaba3754d2c951ee62906db398052f5f785bf0c231c81243fd38de58c796048
import operator import uuid from unittest import mock from django import forms from django.core import serializers from django.core.exceptions import ValidationError from django.core.serializers.json import DjangoJSONEncoder from django.db import ( DataError, IntegrityError, NotSupportedError, OperationalError, co...
bacbd63d413a5709e1c40eb7c8577c3c09419256b460693fe99588cb9face828
import os import sys from distutils.sysconfig import get_python_lib from setuptools import setup # Warn if we are installing over top of an existing installation. This can # cause issues where files that were deleted from a more recent Django are # still present in site-packages. See #18115. overlay_warning = False i...
979af634b0a2fe07bacb6e800943895c5eb32640f7b697e648389bacf8aa4261
#!/usr/bin/env python import argparse import atexit import copy import gc import os import shutil import socket import subprocess import sys import tempfile import warnings from pathlib import Path try: import django except ImportError as e: raise RuntimeError( 'Django module not found, reference tests...
f2750117059b25e41144b8d993f2c484bdfdc7b2118bcd6bfb60afdddd954401
# This is an example test settings file for use with the Django test suite. # # The 'sqlite3' backend requires only the ENGINE setting (an in- # memory database will be used). All other backends will require a # NAME and potentially authentication information. See the # following section in the docs for more informatio...
23e573f134fe6144cc0ea89451c9e96c57e05764488d02f5bedf8f5735e713c8
# 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...
b9de15702c7e64b2a7619ae07c4583061a2da16669da5543fb062fbec26db78c
import logging import threading import weakref from django.utils.inspect import func_accepts_kwargs logger = logging.getLogger('django.dispatch') def _make_id(target): if hasattr(target, '__func__'): return (id(target.__self__), id(target.__func__)) return id(target) NONE_ID = _make_id(None) # A ...
9b25073c5d0c4efd344368f8464c66cf7d310c9fb59b8bc91b063d74122883b2
import argparse import ctypes import faulthandler import hashlib import io import itertools import logging import multiprocessing import os import pickle import random import sys import textwrap import unittest import warnings from collections import defaultdict from contextlib import contextmanager from importlib impo...
a716c582bc2a572177f6fb9adc75d896c8590b98b720ec0bee3f0692614c6f6c
import json import mimetypes import os 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 asgiref.sync import sync_to_async from django.conf im...
cfc0b4be1ea8504e3541a24bd08731edcb0aeda55b7627871f0781a7fd0e4a02
import asyncio import difflib import json import logging import posixpath import sys import threading import unittest import warnings from collections import Counter from contextlib import contextmanager from copy import copy, deepcopy from difflib import get_close_matches from functools import wraps from unittest.suit...
cceb1d927ef408fae6c286081bac946d52d8acb779f0c39e835a5681837a5ccf
import asyncio import collections import logging import os 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.d...
d80e4e20f95e6232ac909572a71d17227fe810663934c5fbaac3e9671f363d37
import functools import re import sys import types import warnings from pathlib import Path from django.conf import settings from django.http import Http404, HttpResponse, HttpResponseNotFound from django.template import Context, Engine, TemplateDoesNotExist from django.template.defaultfilters import pprint from djang...
8fa2e05adaeed8ce0c9bbe74377dcbfe6bbea948aec5f7639888dbb49090bda1
from django.conf import settings from django.http import HttpResponseForbidden from django.template import Context, Engine, TemplateDoesNotExist, loader from django.utils.translation import gettext as _ from django.utils.version import get_docs_version # We include the template inline since we need to be able to relia...
b483c256b2288d5e333444c55593eb8d9c05337ae9d90d5b23f2a31b030466d7
""" 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 warnings from pathlib impor...
12a5e624f3b1181ff2473d86992f85c0e713a33240c47d6790e34c6b66ec8c10
""" 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 ####...
235facedb87f4d9cc9074a717fd52faa1d404d3055ba05557993e6cb4e6c6954
# These classes override date and datetime to ensure that strftime('%Y') # returns four digits (with leading zeros) on years < 1000. # https://bugs.python.org/issue13305 # # Based on code submitted to comp.lang.python by Andrew Dalke # # >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A") # '0010/08/02 was a...
1b0e832ea4a5606216d2d2dc69391214bc0a92e5ff68ce88d71afa6c617123c9
import functools import itertools import logging import os import signal import subprocess import sys import threading import time import traceback import weakref from collections import defaultdict from pathlib import Path from types import ModuleType from zipimport import zipimporter import django from django.apps i...
07a792d9d8882f760f523a74056df237a5307015e6c6115eb516b86dc2834c82
import html.entities import re import unicodedata from gzip import GzipFile, compress as gzip_compress from io import BytesIO from django.core.exceptions import SuspiciousFileOperation from django.utils.functional import SimpleLazyObject, keep_lazy_text, lazy from django.utils.regex_helper import _lazy_re_compile from...
98bc80f3939ef82f200a67212b6821791d415391b5dd1f7474f0bc3cecbdf585
"""Functions to parse datetime objects.""" # We're using regular expressions rather than time.strptime because: # - They provide both validation and parsing. # - They're more flexible for datetimes. # - The date/datetime/time constructors produce friendlier error messages. import datetime from django.utils.regex_hel...
d926839f0d047ffcc4d94d0f634ed9e9d53cc7c04bfeb74423b73f0c851d829c
import datetime import functools import os import subprocess import sys from django.utils.regex_helper import _lazy_re_compile # Private, stable API for detecting the Python version. PYXY means "Python X.Y # or later". So that third-party apps can use these values, each constant # should remain as long as the oldest ...
7d395a8b7b6e8b46bf1cd168682bf171ecb720836510746718a2dda2e96de728
""" Timezone-related classes and functions. """ import functools from contextlib import ContextDecorator from datetime import datetime, timedelta, timezone, tzinfo import pytz from asgiref.local import Local from django.conf import settings __all__ = [ 'utc', 'get_fixed_timezone', 'get_default_timezone', 'g...
d79f69a2634f9aa9b71897e3abdbe30dd1cd435ff2e70d181562eab5520ea73e
""" A class for storing a tree graph. Primarily used for filter constructs in the ORM. """ import copy from django.utils.hashable import make_hashable class Node: """ A single internal node in the tree graph. A Node should be viewed as a connection (the root) with the children being either leaf nodes or...
213c6dcd680b1156d26af317989df6779e3d55897944392b47b3c480b38cc590
import codecs import datetime import locale from decimal import Decimal from urllib.parse import quote from django.utils.functional import Promise class DjangoUnicodeDecodeError(UnicodeDecodeError): def __init__(self, obj, *args): self.obj = obj super().__init__(*args) def __str__(self): ...
4c2b83b70b5d167626578de6c8eee8f8b9a9af5014a209882ed8be7e879bf1e1
import copy from collections.abc import Mapping class OrderedSet: """ A set which keeps the ordering of the inserted items. """ def __init__(self, iterable=None): self.dict = dict.fromkeys(iterable or ()) def add(self, item): self.dict[item] = None def remove(self, item): ...
88e82d744fe0137d82f2d65affba68909174992bcb1387cabb0832da66529577
""" PHP date() style date formatting See http://www.php.net/date for format strings Usage: >>> import datetime >>> d = datetime.datetime.now() >>> df = DateFormat(d) >>> print(df.format('jS F Y H:i')) 7th October 2003 11:39 >>> """ import calendar import datetime from email.utils import format_datetime as format_datet...
f3b48257489e9b6ffee2cade6cef8cee49613e6e9092f287e517ab6b66b42d4f
# RemovedInDjango50Warning # Copyright (c) 2010 Guilherme Gondim. All rights reserved. # Copyright (c) 2009 Simon Willison. All rights reserved. # Copyright (c) 2002 Drew Perttula. All rights reserved. # # License: # Python Software Foundation License version 2 # # See the file "LICENSE" for terms & conditions for us...
11ff9ac7b40e4fe25a64576ebf7b5cba8a12f7d40580fb6cb5cb56f80b53e9ac
"""HTML utilities suitable for global use.""" import html import json import re from html.parser import HTMLParser from urllib.parse import ( parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit, ) from django.utils.encoding import punycode from django.utils.functional import Promise, keep_lazy, keep_lazy_t...
9062c5b975940700caf7d1d63f2a21ede017e83ef7e769887519a40eae5e743d
import logging import logging.config # needed when logging_config doesn't start with logging.config from copy import copy from django.conf import settings from django.core import mail from django.core.mail import get_connection from django.core.management.color import color_style from django.utils.module_loading impo...
f14e22f45807fd7b122ac27cbb10c0bf396073dedc44f823e214493993fea626
""" Syndication feed generation library -- used for generating RSS, etc. Sample usage: >>> from django.utils import feedgenerator >>> feed = feedgenerator.Rss201rev2Feed( ... title="Poynter E-Media Tidbits", ... link="http://www.poynter.org/column.asp?id=31", ... description="A group blog by the sharpest ...
6dc08f2bd5bb820bf927a1adb26103f08a10a7d5781512fcbde3c227fec25c67
import asyncio import functools import os from django.core.exceptions import SynchronousOnlyOperation def async_unsafe(message): """ Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message. """ def decorator(func): ...
cd4b52d0d21fbfaba862c7a6e67936d2e9cd40f3dcce5f71ff4ffd4b901a8530
import base64 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, scheme_chars, urlencode as original_urlencode, uses_params, ) from django.util...
b7922cbbed9c1f6a972f5c60da5ef86813a07d2b13c44b1f316501f93df49438
import datetime import decimal import functools import re import unicodedata from importlib import import_module from django.conf import settings from django.utils import dateformat, numberformat from django.utils.functional import lazy from django.utils.translation import ( check_for_language, get_language, to_lo...
c8db35dd9bccd40de05fde65ca8ba5ff9b365304ee5b10624166a762df6360cb
"""JsLex: a lexer for JavaScript""" # Originally from https://bitbucket.org/ned/jslex import re class Tok: """ A specification for a token class. """ num = 0 def __init__(self, name, regex, next=None): self.id = Tok.num Tok.num += 1 self.name = name self.regex = re...
5f91babe297e9e1265cb4bc110514a7d6ea0a48fcc41196abb430ee846e2a6e3
from pathlib import Path from django.dispatch import receiver from django.template import engines from django.template.backends.django import DjangoTemplates from django.utils._os import to_path from django.utils.autoreload import ( autoreload_started, file_changed, is_django_path, ) def get_template_directories...
3511072a047c9a8d5413c0cdad5dae88899abbcc243e33f4b9e7205498167cb7
import posixpath from collections import defaultdict from django.utils.safestring import mark_safe from .base import ( Node, Template, TemplateSyntaxError, TextNode, Variable, token_kwargs, ) from .library import Library register = Library() BLOCK_CONTEXT_KEY = 'block_context' class BlockContext: def __in...
3d0881e9aeb22104d7380a9dedbb252bb6376c197cf7d7bdfbb1f710c4a1390b
""" 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...
961110d9dd0124bbad2d0e2c9950d049097aa27f8e93ab864903150d801df1d4
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 Template from .context import Context, _builtin_context_processors from .exceptions import TemplateDoesNotExist from .lib...
6a8e4d1b56432526dd4c6ef7911223d5c03107dd2d6a13ef2581ca18c3b49559
"""Default tags used by the template system, available to all templates.""" import re import sys import warnings from collections import namedtuple from datetime import datetime from itertools import cycle as itertools_cycle, groupby from django.conf import settings from django.utils import timezone from django.utils....
44d31d64b7e97689a737cedc2f09cfb63ea00f51f25d7eab4d2b5ee9a39dca01
import functools from importlib import import_module from inspect import getfullargspec, unwrap from django.utils.html import conditional_escape from django.utils.itercompat import is_iterable from .base import Node, Template, token_kwargs from .exceptions import TemplateSyntaxError class InvalidTemplateLibrary(Exc...
217a7a697536dae38d315ae8ebcd68d0750942d29227a82884e99dc10a1c978c
import re from django.conf import settings from django.http import HttpResponsePermanentRedirect from django.utils.deprecation import MiddlewareMixin class SecurityMiddleware(MiddlewareMixin): def __init__(self, get_response): super().__init__(get_response) self.sts_seconds = settings.SECURE_HSTS...
e6ca4d6c766dd48427d815877f35dc40dd564abe17d5fc779e1aade9e7bdb0b9
""" Cross Site Request Forgery Middleware. This module provides a middleware that implements protection against request forgeries from other sites. """ import logging import string from collections import defaultdict from urllib.parse import urlparse from django.conf import settings from django.core.exceptions import...
216c26380a35f69dd84ac22b52fdd3dd8009064fc755cc09795e9ec6cfbad308
"""Functions for use in URLsconfs.""" from functools import partial from importlib import import_module from django.core.exceptions import ImproperlyConfigured from .resolvers import ( LocalePrefixPattern, RegexPattern, RoutePattern, URLPattern, URLResolver, ) def include(arg, namespace=None): app_name = No...
6aeb0ed9dedc20f915c97ad0f7453a910ce25b4b65f6b4c1068a91aba918050f
""" 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 string from i...
a260984e03c7ae94089b14100b7b847264648428087bd20a0531b6a565a24fe7
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 CheckboxInput, HiddenInput, NumberInput from django.utils.functional import cached_property from django.ut...
af0a60022cc23b0a5473d7a8538ee568fbf189458688968ddc67c4941fac34b6
""" HTML Widget classes """ import copy import datetime import warnings from collections import defaultdict from itertools import chain from django.forms.utils import to_current_timezone from django.templatetags.static import static from django.utils import formats from django.utils.datastructures import OrderedSet f...
63bb1004d952108003de51daacdafd544d268cdbca92690f4585f1fcad8eed9d
import re from django.core.exceptions import ValidationError from django.forms.utils import flatatt, pretty_name from django.forms.widgets import Textarea, TextInput from django.utils.functional import cached_property from django.utils.html import conditional_escape, format_html, html_safe from django.utils.safestring...
3ccbe611038e656d4e2afa17d3edc58b802b4f3334f6d7c5d1cbb0608a27f71d
""" Field classes. """ import copy import datetime import json import math import operator import os import re import uuid from decimal import Decimal, DecimalException from io import BytesIO from urllib.parse import urlsplit, urlunsplit from django.core import validators from django.core.exceptions import Validation...
8613b4bd6eb12c7bc6f363222dbc6dbd32e122ea93eeea10b1e57c6e8d4b7c30
""" Form classes """ import copy import datetime from django.core.exceptions import NON_FIELD_ERRORS, ValidationError from django.forms.fields import Field, FileField from django.forms.utils import ErrorDict, ErrorList from django.forms.widgets import Media, MediaDefiningClass from django.utils.datastructures import ...
b7d3ebcab76ffeb153a32194ba7a2454d726b8fa08fece9b410f29709046e60f
""" Functions for creating and restoring url-safe signed JSON objects. The format used looks like this: >>> signing.dumps("hello") 'ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk' There are two components here, separated by a ':'. The first component is a URLsafe base64 encoded JSON of the object passed to dumps(). T...
938172d2870fc8e293bb61256ce489b9541cae4021abb58fc60930c69707d5ad
import ipaddress import re import warnings from pathlib import Path from urllib.parse import urlsplit, urlunsplit from django.core.exceptions import ValidationError from django.utils.deconstruct import deconstructible from django.utils.deprecation import RemovedInDjango41Warning from django.utils.encoding import punyc...
dc930bf48e0e628263906bc4d2d7d1e44f63dd558392b0f31d8a3763f2d62da0
""" Multi-part parsing for file uploads. Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to file upload handlers for processing. """ import base64 import binascii import cgi import collections import html from urllib.parse import unquote from django.conf import settings from django.core.ex...
be079ba4856186f27ff6001ecda087b426b1f0d248453cbb573fb50e50050bc4
import datetime import json import mimetypes import os import re import sys import time from collections.abc import Mapping 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.co...
0360e9e660a229887f91f86940c77a4a150712090eb1db2ae34cfa8f26610027
import cgi import codecs import copy from io import BytesIO from itertools import chain from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlsplit from django.conf import settings from django.core import signing from django.core.exceptions import ( DisallowedHost, ImproperlyConfigured, RequestDataTooB...
93e5d46bd8a119e0f64ae6fe8b9f9af649ec2d8d0edc2d75f7eadc1e03d327f3
from urllib.parse import quote, urljoin from django import template from django.apps import apps from django.utils.encoding import iri_to_uri from django.utils.html import conditional_escape register = template.Library() class PrefixNode(template.Node): def __repr__(self): return "<PrefixNode for %r>" ...
adbe25c9674513ed40f1b45177c1b7f578b390638d8c42e77f9c0361d9a894d9
from decimal import Decimal from django.conf import settings from django.template import Library, Node, TemplateSyntaxError, Variable from django.template.base import TokenType, render_value_in_context from django.template.defaulttags import token_kwargs from django.utils import translation from django.utils.safestrin...
f29800e221df6686c468814d3730239155fb752f0edc4480924c97d841a5b631
""" Decorators for views based on HTTP headers. """ from functools import wraps from django.http import HttpResponseNotAllowed from django.middleware.http import ConditionalGetMiddleware from django.utils import timezone from django.utils.cache import get_conditional_response from django.utils.decorators import decor...
100d20c4ad792a8dc8018a3d8411f46677fb0b44ba5a779899cdf58df90298ca
import functools from django.http import HttpRequest def sensitive_variables(*variables): """ Indicate which variables used in the decorated function are sensitive so that those variables can later be treated in a special way, for example by hiding them when logging unhandled exceptions. Accept ...
f59f05fe3f90bc2b2b034a7f7866b4498be9bfbf7607c03824d78c96f6924d0a
from django.core.exceptions import ImproperlyConfigured from django.forms import Form, models as model_forms from django.http import HttpResponseRedirect from django.views.generic.base import ContextMixin, TemplateResponseMixin, View from django.views.generic.detail import ( BaseDetailView, SingleObjectMixin, Singl...
9c49fd23b913b6334036fb8c4ec2edcbd17fd4fab9e6daa3e59f8882cd4fc032
"""Translation helper functions.""" import functools import gettext as gettext_module import os import re import sys import warnings from asgiref.local import Local from django.apps import apps from django.conf import settings from django.conf.locale import LANG_INFO from django.core.exceptions import AppRegistryNotR...
35301041b0705d76bc1b19991c39cc080abbe10a05a55c7100e27546b9e37723
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 - ...
64123ed6fa5c8535388a2b7324c0abe83077636b755d67d842363170b02b333d
import copy from collections import defaultdict from contextlib import contextmanager from functools import partial from django.apps import AppConfig from django.apps.registry import Apps, apps as global_apps from django.conf import settings from django.core.exceptions import FieldDoesNotExist from django.db import mo...
29f7bbf18a831fa5d32d56ddca34ceacd4fe4aa509e69305fefef5d55ad30bb0
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...
6eddebec4e9d4d4f53fe81edb20f46f601e52cbfd1b22bebf6677f03a66a79cd
from functools import total_ordering from django.db.migrations.state import ProjectState from .exceptions import CircularDependencyError, NodeNotFoundError @total_ordering class Node: """ A single node in the migration graph. Contains direct links to adjacent nodes in either direction. """ def _...
44653e6bcbec1e3a18cc926b628ca63ce72c3705fdc319a0cf00e262f533ecb8
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 ...
13e33d4ac253b04b3c20385c6514aeb5f2c2fd1fe621b2a11f0c1ea91f9275b0
import datetime import re from collections import namedtuple from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT FieldReference = namedtuple('FieldReference', 'to through') COMPILED_REGEX_TYPE = type(re.compile('')) class RegexObject: def __init__(self, obj): self.pattern = obj....
ba6a6b26c999b603dbb7469baae87d1da6e35d8da72c271e03ae84ca57840526
import builtins import collections.abc import datetime import decimal import enum import functools import math import os import pathlib import re import types import uuid from django.conf import SettingsReference from django.db import models from django.db.migrations.operations.base import Operation from django.db.mig...
71262dd26d9fdb2de8a060fe31d9e72604587e0cf31f0dce487f22f4e13ad894
""" 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.comparison import Coalesce from django.db.models.functions.m...
bef6b0eb56d99b68392a1942110343830d9a058028c6cbd5f53a74912d3be484
from django.db.backends.utils import names_digest, split_identifier from django.db.models.expressions import Col, ExpressionList, F, Func, OrderBy from django.db.models.functions import Collate from django.db.models.query_utils import Q from django.db.models.sql import Query from django.utils.functional import partitio...
9911d1a956989731db91344e6b5a282a7a108b742211dff0ac05ae37a9ace7ae
""" The main QuerySet implementation. This provides the public API for the ORM. """ import copy import operator import warnings from itertools import chain import django from django.conf import settings from django.core import exceptions from django.db import ( DJANGO_VERSION_PICKLE_KEY, IntegrityError, NotSuppor...
2a727a1b507676ea6f6a78e037c7a105aa61067627ecbbab0dca5f9dbe8d6ce3
import enum from types import DynamicClassAttribute from django.utils.functional import Promise __all__ = ['Choices', 'IntegerChoices', 'TextChoices'] class ChoicesMeta(enum.EnumMeta): """A metaclass for creating a enum choices.""" def __new__(metacls, classname, bases, classdict, **kwds): labels =...
ca9548b655cb47b1aac737c0e78f570f38f43b2f1e7123a6d52cb7e013539a95
import copy import inspect import warnings from functools import partialmethod from itertools import chain import django 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, MultipleObjects...
bf084e6c978795f169fe7054dcbddc2f63ec6083971fb8ceb4d56a4dfd2e3beb
import functools from collections import namedtuple def make_model_tuple(model): """ Take a model or a string of the form "app_label.ModelName" and return a corresponding ("app_label", "modelname") tuple. If a tuple is passed in, assume it's a valid model tuple already and return it unchanged. """...
ef76721c50920bc994f64cae93435949f1a3ad4b05caaa69cd3e8a603a592c73
""" 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...
e77160b47c011fa1ba49f374af5d4215ebfd031fbc82bdb5aca4ca2dc1178d18
import copy import datetime import functools import inspect from decimal import Decimal from uuid import UUID from django.core.exceptions import EmptyResultSet, FieldError from django.db import DatabaseError, NotSupportedError, connection from django.db.models import fields from django.db.models.constants import LOOKU...
5fd890de7db4f51c6664417f80eefaae9490bffb3ddd2aa0bbec9b402a6c3458
from collections import Counter, defaultdict from functools import partial from itertools import chain from operator import attrgetter from django.db import IntegrityError, connections, transaction from django.db.models import query_utils, signals, sql class ProtectedError(IntegrityError): def __init__(self, msg...
7aa3ca034b33c576bb2a8232e55efa79734ab9310ba8fed4202da9e79aa8205b
import itertools import math from django.core.exceptions import EmptyResultSet from django.db.models.expressions import Case, Expression, Func, Value, When from django.db.models.fields import ( BooleanField, CharField, DateTimeField, Field, IntegerField, UUIDField, ) from django.db.models.query_utils import Regist...
4c76ca31940ab36d721e5d95eee70b2c31f6a33361e913319c46cb6b4d2051d9
from enum import Enum from django.db.models.expressions import ExpressionList, F from django.db.models.indexes import IndexExpression from django.db.models.query_utils import Q from django.db.models.sql.query import Query __all__ = ['CheckConstraint', 'Deferrable', 'UniqueConstraint'] class BaseConstraint: def ...
b0f203f860fee996fe0d2dabf6551393613d2d1b72c058bc4ef01b16fedf6ab9
import datetime import decimal import functools import hashlib import logging import time from contextlib import contextmanager from django.db import NotSupportedError logger = logging.getLogger('django.db.backends') class CursorWrapper: def __init__(self, cursor, db): self.cursor = cursor self....
09caa2eb9a019d08af8a903deaa8847ebf88f8921fa5c029e55dc676839e3c88
from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.state import ModelState from django.db.migrations.utils import field_references, resolve_relation from django.db.models.options import normalize_together from django.utils.functional import cached_property ...
8dc47ee887cb834a5109dca617abdfc22c42642e612210aea2b54b839607138d
from django.db.migrations.utils import field_references from django.db.models import NOT_PROVIDED from django.utils.functional import cached_property from .base import Operation class FieldOperation(Operation): def __init__(self, model_name, name, field=None): self.model_name = model_name self.na...
8fd41b5dbe7b7f485dc9ed9d45725011b4e9ae484f1be96759a2e9558e3288d3
from django.db.models.lookups import ( Exact, GreaterThan, GreaterThanOrEqual, In, IsNull, LessThan, LessThanOrEqual, ) class MultiColSource: contains_aggregate = False def __init__(self, alias, targets, sources, field): self.targets, self.sources, self.field, self.alias = targets, sources, f...
1009e42a3c5bbb8a563cf80a05ac2f2dfc734a7073f9634437ac39024cbc46b9
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...
2388508b0698b74c3bae77a28d383806765e3ff2f4ef657f5bab7254753a21fa
import functools import inspect from functools import partial from django import forms from django.apps import apps from django.conf import SettingsReference, settings from django.core import checks, exceptions from django.db import connection, router from django.db.backends import utils from django.db.models import Q...
2bae041c9fb0a25dc254177e32fa39764222e4ff6ae353caedd1cad5f06115c6
import datetime import posixpath from django import forms from django.core import checks from django.core.files.base import File from django.core.files.images import ImageFile from django.core.files.storage import Storage, default_storage from django.core.files.utils import validate_file_name from django.db.models imp...
784c23ef4a0734904eda532c09385e2b7747b5dc8950213a2f94b6e16758987a
""" 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...
144e533f6555d3cdf555d5b7973c3be9b01be502c7e7d375f8855d77c9f3849d
""" "Rel objects" for related fields. "Rel objects" (for lack of a better name) carry information about the relation modeled by a related field and provide some utility functions. They're stored in the ``remote_field`` attribute of the field. They also act as reverse fields for the purposes of the Meta API because th...
bd0927c99a782b228ba74392305b45de6e2dba132301bbd18611a5e294632d74
"""Database functions that do comparisons or type conversions.""" from django.db import NotSupportedError from django.db.models.expressions import Func, Value from django.db.models.fields.json import JSONField from django.utils.regex_helper import _lazy_re_compile class Cast(Func): """Coerce an expression to a ne...
47af44ecd06bd03357c123804ead482dcce5ebbea766a921fe11d27e5c6f8353
from datetime import datetime from django.conf import settings from django.db.models.expressions import Func from django.db.models.fields import ( DateField, DateTimeField, DurationField, Field, IntegerField, TimeField, ) from django.db.models.lookups import ( Transform, YearExact, YearGt, YearGte, YearLt, Yea...
2fa9acb5f7849a85b8be0d40b29d4ca98bb6e486f57e92b6a5e788e29d88ca33
""" Create SQL statements for QuerySets. The code in here encapsulates all of the SQL construction so that QuerySets themselves do not have to (and could be backed by things other than SQL databases). The abstraction barrier only works one way: this module has to know all about the internals of models in order to get ...
a75d17444449fa850c328f58a9c987d35382b0d63b1767bcc63b143f924ec2d8
import collections import json import re from functools import partial from itertools import chain from django.core.exceptions import EmptyResultSet, FieldError from django.db import DatabaseError, NotSupportedError from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import F, OrderBy, ...
a4874da7febd6573728f75aeee8d7f622c9907ba9debf803f864cf8ac9ff60cd
""" Code to manage the creation and SQL rendering of 'where' constraints. """ from django.core.exceptions import EmptyResultSet from django.utils import tree from django.utils.functional import cached_property # Connection types AND = 'AND' OR = 'OR' class WhereNode(tree.Node): """ An SQL WHERE clause. ...
a68fc1d6fddb6dde3973ae6561b5fdddef6aea9e58ed10aad0ce78ae024bd224
""" Useful auxiliary data structures for query construction. Not useful outside the SQL domain. """ from django.db.models.sql.constants import INNER, LOUTER class MultiJoin(Exception): """ Used by join construction code to indicate the point at which a multi-valued join was attempted (if the caller wants ...
02b902381b15f0ab9c18779deaa63924913eef3f6c9d1e564c3e1a2b317ed2d7
""" Query subclasses which provide extra functionality beyond simple data retrieval. """ from django.core.exceptions import FieldError from django.db.models.sql.constants import ( CURSOR, GET_ITERATOR_CHUNK_SIZE, NO_RESULTS, ) from django.db.models.sql.query import Query __all__ = ['DeleteQuery', 'UpdateQuery', '...
9f4978fa969a675c5c2144f50d961c54ffdbed3524f2e943e129693f41f0703f
from django.db import DatabaseError, InterfaceError from django.db.backends.base.features import BaseDatabaseFeatures from django.utils.functional import cached_property class DatabaseFeatures(BaseDatabaseFeatures): # Oracle crashes with "ORA-00932: inconsistent datatypes: expected - got # BLOB" when grouping...
f3da2493ffd66ba73299fc3c8161165ae1331b6ac79a31a17c53bce38149dbb7
import datetime import uuid from functools import lru_cache from django.conf import settings from django.db import DatabaseError, NotSupportedError from django.db.backends.base.operations import BaseDatabaseOperations from django.db.backends.utils import strip_quotes, truncate_name from django.db.models import AutoFie...
bf82e497851f90b53d05f86105237afceeaf7faa6aa1cb12caff8de070d45d3b
from django.db import ProgrammingError from django.utils.functional import cached_property class BaseDatabaseFeatures: gis_enabled = False # Oracle can't group by LOB (large object) data types. allows_group_by_lob = True allows_group_by_pk = False allows_group_by_selected_pks = False empty_fet...
ef0914cd4f3a302d9043e473b244fb716aa2b95efb43da6fdb4ecb83c95318d2
import logging from datetime import datetime from django.db.backends.ddl_references import ( Columns, Expressions, ForeignKeyName, IndexName, Statement, Table, ) from django.db.backends.utils import names_digest, split_identifier from django.db.models import Deferrable, Index from django.db.models.sql import Query...
23972aebf88221fa1893282f58e48c5d03595bc345f96601cb930a23d2979570
import os import subprocess class BaseDatabaseClient: """Encapsulate backend-specific methods for opening a client shell.""" # This should be a string representing the name of the executable # (e.g., "psql"). Subclasses must override this. executable_name = None def __init__(self, connection): ...
d58d5cf21f018e449e1b86e45eb0091aef696a88b99ffc6bcae27454a89df0f5
import operator from django.db.backends.base.features import BaseDatabaseFeatures from django.utils.functional import cached_property class DatabaseFeatures(BaseDatabaseFeatures): empty_fetchmany_value = () allows_group_by_pk = True related_fields_match_type = True # MySQL doesn't support sliced subq...
76aa3988f37ba83142216f89e6aa8b9083a89c3e51984f99d89c7add289b04df
from django.core.exceptions import FieldError from django.db.models.expressions import Col from django.db.models.sql import compiler class SQLCompiler(compiler.SQLCompiler): def as_subquery_condition(self, alias, columns, compiler): qn = compiler.quote_name_unless_alias qn2 = self.connection.ops.q...