hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
c5d8ab81e54c416256aaa93e94d2b421f60ac3269eb441426abd6761c38de43a | from django.contrib.gis.db import models
from ..utils import gisfield_may_be_null
class NamedModel(models.Model):
name = models.CharField(max_length=30)
class Meta:
abstract = True
def __str__(self):
return self.name
class SouthTexasCity(NamedModel):
"City model on projected coord... |
39df890d983f71feddf8f84570c6492955fecd989757b69713cfd5d99962f9f5 | import itertools
import json
import os
import re
from django.apps import apps
from django.conf import settings
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from django.template import Context, Engine
from django.urls import translate_url
from django.utils.formats import get_format
from djan... |
3e72b3c90b6e1bf9bb0d77b2684fe6df8bc7e61ccedae3d69ba00fa2cda03f90 | """
Based on "python-archive" -- https://pypi.org/project/python-archive/
Copyright (c) 2010 Gary Wilson Jr. <gary.wilson@gmail.com> and contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Softw... |
991afd766d879139fd6abdf05c040a508bc52cc038460eb34f370f7b35377ca3 | 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... |
b1fa9d73dc9c6873504ab270b4646eb91e5cd202f9f0a9fffff2342e2183d8ab | from urllib.parse import unquote, urlsplit, urlunsplit
from asgiref.local import Local
from django.utils.functional import lazy
from django.utils.translation import override
from .exceptions import NoReverseMatch, Resolver404
from .resolvers import _get_cached_resolver, get_ns_resolver, get_resolver
from .utils impo... |
bf021ee9e6e1e4f852f5171fb9e14d87aa40806a9ab4458da7f0e62a4b9311d9 | """
Helper functions for creating Form classes from Django models
and database field objects.
"""
from itertools import chain
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
)
from django.forms.fields import ChoiceField, Field
from django.forms.forms import... |
98e7022747b6afbfcc6a0ca525c974e17a04649afd5acd989a271297897e0451 | """
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 datetime_safe, formats
from django.utils.datastructures impo... |
393deef7c8504fd027b727c79f2d067d1e3b9e0b4ba55f8cd7bea16b8c9006b7 | 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... |
98b52cab5ff87037bc877b69589c4a67d22fbea1522a7da4cb2cfc31226e1353 | """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... |
d82564916078d406515b071f97d4b9719f971922b3699dfe8eff7d3c819c2ce8 | 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... |
7e40abc39fe3728ee5298dcd2364614c65baee69425924a55300ffd05d2156c1 | 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... |
acb6083f3f086d78324aa7258d247c3df628f02ac542308aa83a33c05f841a71 | """
PostgreSQL database backend for Django.
Requires psycopg 2: https://www.psycopg.org/
"""
import asyncio
import threading
import warnings
from contextlib import contextmanager
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError as WrappedDat... |
119cdefbdcb6ae49b4ab3acd0f8a7fd16a39f719a8f25de8d499becc9c416886 | from unittest import mock
from django.contrib.postgres.indexes import (
BloomIndex, BrinIndex, BTreeIndex, GinIndex, GistIndex, HashIndex, OpClass,
SpGistIndex,
)
from django.db import NotSupportedError, connection
from django.db.models import CharField, F, Index, Q
from django.db.models.functions import Cast,... |
182eb90312aeb632024fbf2a8a9607429447248461eb9b109d476e1d34ea65e1 | import datetime
from unittest import mock
from django.db import (
IntegrityError, NotSupportedError, connection, transaction,
)
from django.db.models import (
CheckConstraint, Deferrable, F, Func, IntegerField, Q, UniqueConstraint,
)
from django.db.models.fields.json import KeyTextTransform
from django.db.mode... |
2a5a38d1b7f1a2f196bdd9f84505a8105e06bfa961c20c1aa03cec8f3e88322d | import os
import stat
import sys
import tempfile
import unittest
from django.core.exceptions import SuspiciousOperation
from django.test import SimpleTestCase
from django.utils import archive
class TestArchive(unittest.TestCase):
def setUp(self):
self.testdir = os.path.join(os.path.dirname(__file__), 'a... |
a7f7b200494a6c1fa355131194ebed6c2b3824c0b529721603c97248f88bd011 | import os
from django.template import Context, Engine, TemplateSyntaxError
from django.test import SimpleTestCase
from .utils import ROOT
RELATIVE = os.path.join(ROOT, 'relative_templates')
class ExtendsRelativeBehaviorTests(SimpleTestCase):
def test_normal_extend(self):
engine = Engine(dirs=[RELATIVE... |
8b694427d549722cfea8f33f1ea5605924fed22ed205df64a2997312a6a82728 | import os
import pathlib
from unittest import mock, skipUnless
from django.conf import settings
from django.contrib.gis.geoip2 import HAS_GEOIP2
from django.contrib.gis.geos import GEOSGeometry
from django.test import SimpleTestCase
if HAS_GEOIP2:
from django.contrib.gis.geoip2 import GeoIP2, GeoIP2Exception
# ... |
4332053c514b98de9190287305bbabfdd773e4f9252c24fe1a5b0dc970757952 | import datetime
import pickle
import unittest
import uuid
from collections import namedtuple
from copy import deepcopy
from decimal import Decimal
from unittest import mock
from django.core.exceptions import FieldError
from django.db import DatabaseError, NotSupportedError, connection
from django.db.models import (
... |
01b36442c2996d7a34414d7b84fea8c6968ad8c88e8504f1ca5e575a6ff472e1 | import copy
import json
import os
import pickle
import unittest
import uuid
from django.core.exceptions import DisallowedRedirect
from django.core.serializers.json import DjangoJSONEncoder
from django.core.signals import request_finished
from django.db import close_old_connections
from django.http import (
BadHead... |
3f1ba4ffff395c97ebbd11eacdd01837440d276735c9b323a58f1fc2a0c6ead5 | from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import (
BooleanField, CharField, ChoiceField, DateField, DateTimeField,
DecimalField, EmailField, FileField, FloatField, Form,
GenericIPAddressField, IntegerField, ModelChoiceF... |
fe743a51d76c4e4209a779c3ea9098f7301fbf10f46f2149173882d404434fe8 | import gettext
import json
from os import path
from django.conf import settings
from django.test import (
RequestFactory, SimpleTestCase, TestCase, modify_settings,
override_settings,
)
from django.test.selenium import SeleniumTestCase
from django.urls import reverse
from django.utils.translation import get_la... |
99ab755efb300f09efcea48cf0485323c8d4516cde028774f2661065d8610075 | import copy
import unittest
from io import StringIO
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connection, connections
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test import TestCase, override_se... |
5e0aedce8ca9f1c09e8ffa30331c36c5bc688f6f1f1c1757a64fe9c28bf02cf4 | import datetime
import decimal
from django.db import connection, models
from django.db.models.functions import Cast
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from ..models import Author, DTModel, Fan, FloatModel
class CastTests(TestCase):
@classmethod
def setUpTestData(self):
... |
c563b1a8d1a2379f2aa36e090da97294006da14e0733e954c6d7ea414534ad1e | import os
import sys
from distutils.sysconfig import get_python_lib
from setuptools import setup
CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 8)
# This check and everything above must remain compatible with Python 2.7.
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write("""
=====================... |
a476ce0435b2947e207f4cf905f0a59bc6a3db8a2a37168b8094a62dd6b00b8f | #!/usr/bin/env python
import argparse
import atexit
import copy
import os
import shutil
import socket
import subprocess
import sys
import tempfile
import warnings
try:
import django
except ImportError as e:
raise RuntimeError(
'Django module not found, reference tests/README.rst for instructions.'
... |
fc31cd70b71d1e165196ffff3dbc2517a74e4cfeeaaa7738c396b29a2f78117e | # 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... |
1822c2dfa1313d68d282c04c1b5a96b4f72282f99d41f6d6fe4025def805ab2b | import ctypes
import faulthandler
import io
import itertools
import logging
import multiprocessing
import os
import pickle
import sys
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... |
7839f06457317c7fbb8937abfc5e2eb9c52c48e0d6f93ebb9ed35899c824d640 | 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... |
29471690773fed1a8fe8e0f377224b514210a23fb5379263c63a002497102b8e | 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... |
6e3cfa4e94b4244329bdc0db31e421bc868d84b5c006c1c87cad2429773f347c | """Compare two HTML documents."""
from html.parser import HTMLParser
from django.utils.regex_helper import _lazy_re_compile
# ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020
# SPACE.
# https://infra.spec.whatwg.org/#ascii-whitespace
ASCII_WHITESPACE = _lazy_re_compile(r'[\t\n\f\r ]+')
# h... |
77b3d071d84193cb3cce420f26bd59c990ddaef25889e25554c358744bf8521b | 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... |
04c2e5f6d979778ea3860d7978bdd0415f712c0aa72d5c50ef8ed46253f7caa8 | import inspect
import os
import warnings
from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango41Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string, module_has_submod... |
bfdc1a9fb7d87aabd41b551f30c09c2961569b7c38116d50be18a6430dc2bdec | 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... |
a964603bf952886c0d9bf39ab87b10c118c340942277d08a7bce6fd5e4117ac4 | 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... |
1ca01a04ddf3c9d423aff8d8ce23d2950da3c057d936e6dac947e3b9563cd6b4 | """
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
from pathlib import Path
from dja... |
b30cc8700209b7d2e6d598b9f5595fd9cfd5cb3ae0bcad0970169c9d5f487272 | """
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
####... |
5c2d5d12ba29d3deeb764185889c481f631d6ce40757bdba6f2a48acb8bcb175 | 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... |
3637821aaaa8d2f71fb57440b7994d2c58ea9627a85f478bac266ed6f4441681 | 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.regex_helper import _lazy_re_compile
from django.utils.translation import gettext as _, gettext_lazy, pgettext
@keep_lazy_tex... |
a0da76208e6cf9443469963d13d1f13edba2b29f55cb73ed60391b683d8d0a2b | import datetime
import functools
import os
import subprocess
import sys
from distutils.version import LooseVersion
# 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 supported Dja... |
3b088bc7e5869072ca57493afb22292dc806ae89b6bddf41aef29b7653f37a1f | import asyncio
import inspect
import warnings
from asgiref.sync import sync_to_async
class RemovedInDjango41Warning(DeprecationWarning):
pass
class RemovedInDjango50Warning(PendingDeprecationWarning):
pass
RemovedInNextVersionWarning = RemovedInDjango41Warning
class warn_about_renamed_method:
def _... |
3b929d027ab9c1deb51e1ed57e0b262b272c8b5dd247b4ae6e67910de6c8b934 | import functools
import inspect
@functools.lru_cache(maxsize=512)
def _get_func_parameters(func, remove_first):
parameters = tuple(inspect.signature(func).parameters.values())
if remove_first:
parameters = parameters[1:]
return parameters
def _get_callable_parameters(meth_or_func):
is_method... |
974fcaaef3f85a31a9c1d7adf3b0b04f5cb9b9bab2f3a002493937ec8ff0d3c8 | 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):
... |
7e61a3f42aa0b25b783b40e38501a01a82c55fab25ae5c562cdedd84e618ec88 | 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:
... |
e5d30a3989e6271cb938028cc152f386204f604fd931a013064aeeb0d9d75f64 | import copy
import itertools
import operator
from functools import total_ordering, wraps
class cached_property:
"""
Decorator that converts a method with a single self argument into a
property cached on the instance.
A cached property can be made out of an existing method:
(e.g. ``url = cached_pr... |
c43a326302420beb015d874c8b29b6078b82bfb6c704fbbb243c0aacebd0dcf6 | 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,
scheme_chars, urlencode as original_urlencode, uses_params,
)
... |
87c09dea5ac31e0b4c0b374d119ee59af93596215920a56d9af41fa3acea9da0 | """
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... |
475e9c93bd89ff395f274743c85efb12bb4811f4f7258e50d3594045a160c5a7 | """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.... |
2b835f8b73a4098c2f54fcbbb50f13c1a396147cfcef8800a39ec232a0864d5c | 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... |
b1fdc32426edf0c473ec3f217448a7a984b89309cfb66e1d18d3e2b50d09538a | """
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 collections import defaultdict
from urllib.parse import urlparse
from django.conf import settings
from django.core.excepti... |
23cff57867349834373d5a9b3accfd1651df2b305e96c8ad3888f9978b95cad4 | """
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... |
9d80b8ab0d5cb59b62bcbdfcf4b3de06b64ccecccaf05371c042b9070cb550f7 | import functools
from pathlib import Path
from django.conf import settings
from django.template.backends.django import DjangoTemplates
from django.template.loader import get_template
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
@functools.lru_cache()
def g... |
6003247943e4609a25210557875f3fbeb328140bcc6f1d141b12d70a8f5285de | from http import cookies
# For backwards compatibility in Django 2.1.
SimpleCookie = cookies.SimpleCookie
def parse_cookie(cookie):
"""
Return a dictionary parsed from a `Cookie:` header string.
"""
cookiedict = {}
for chunk in cookie.split(';'):
if '=' in chunk:
key, val = ch... |
d29e4c66c3f50701de5a6876c9b96c255d6eafe659c74cd4a7fbfa29891d0108 | """
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
import os
from urllib.parse import unquote
from django.conf import settings
from djan... |
676aa6ce7bd682a6409badf556788f7f723002e7f2f9ff5b45e474bf2edd603a | 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... |
88562cec84b1130ebc323b645b424a2187060a35910e3c5fdfa06eb9915b94da | from functools import wraps
from django.http import HttpRequest
from django.middleware.cache import CacheMiddleware
from django.utils.cache import add_never_cache_headers, patch_cache_control
from django.utils.decorators import decorator_from_middleware_with_args
def cache_page(timeout, *, cache=None, key_prefix=Non... |
8b9b01967c005581f4c15a3cad682eed8353e4b591fbcfc0617f4149d1c56dc6 | import logging
from django.core.exceptions import ImproperlyConfigured
from django.http import (
HttpResponse, HttpResponseGone, HttpResponseNotAllowed,
HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils... |
df8c4d8a7f639a7ecb94d9f9bfd97f4e9630da7436e6ce006c54b96cfd01c2ee | """
Internationalization support.
"""
from contextlib import ContextDecorator
from decimal import ROUND_UP, Decimal
from django.utils.autoreload import autoreload_started, file_changed
from django.utils.functional import lazy
from django.utils.regex_helper import _lazy_re_compile
__all__ = [
'activate', 'deactiva... |
ddf721c59c0249c10ae3e5fe7f0eb6e7b20c82c1cf111f26173fd83c4fb7d1e8 | import datetime
import importlib
import os
import sys
from django.apps import apps
from django.db.models import NOT_PROVIDED
from django.utils import timezone
from .loader import MigrationLoader
class MigrationQuestioner:
"""
Give the autodetector responses to questions it might have.
This base class ha... |
3374fc8c386d18e3e8e6e90669506ae76188717f1dda87c7ac9dc26365102756 | from django.db.migrations.utils import get_migration_name_timestamp
from django.db.transaction import atomic
from .exceptions import IrreversibleError
class Migration:
"""
The base class for all migrations.
Migration files will import this from django.db.migrations.Migration
and subclass it as a cla... |
e86b82f45943b7ce8506117fa4bfb031fa1b45f38f05677d64e71c347a9a5e55 | 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... |
66773bcab15bdeaac4165432e5d88d4b0ef193339d4cee593e9e5f33f5641de7 | """
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... |
7ee1504b7bc1a4090c798a6595244163ba87ef01bef11f4a8f10b97f683be4a4 | import enum
from types import DynamicClassAttribute
from django.utils.functional import Promise
from django.utils.version import PY310
__all__ = ['Choices', 'IntegerChoices', 'TextChoices']
class ChoicesMeta(enum.EnumMeta):
"""A metaclass for creating a enum choices."""
def __new__(metacls, classname, base... |
f188895845d55f1634cd885f950d2236969634e98818759fde53ae2b88ee87ea | 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... |
710c51c1a49817475f0b33367b7b44ecde810182006181b3ab5e7aae50a08d4a | """
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 functools
import inspect
from collections import namedtuple
from dj... |
8356dc9ce77645caa3b0ce5be73994fa216b438f92e19865d239730ec261c549 | 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 NotSupportedError, connection
from django.db.models import fields
from django.db.models.constants import LOOKUP_SEP
from djan... |
d78d8bb44450ec55da373a22171df6d2da1a6f8319ade1222f3bc1a9e2537949 | import itertools
import math
from copy import copy
from django.core.exceptions import EmptyResultSet
from django.db.models.expressions import Case, Exists, Func, Value, When
from django.db.models.fields import (
CharField, DateTimeField, Field, IntegerField, UUIDField,
)
from django.db.models.query_utils import Re... |
e2d8bf5c05b8a7bc5686e656d5911a9b1cab1bfb0a6fd720a6c71aef404e8e52 | 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
from django.utils.version import PY310
__all__ = ['CheckConstraint', 'Deferrable', 'UniqueConstr... |
747d33f12be64fb9bec4b05dacf0923988b5ed89332d4af9cb061ca42bd71584 | from django.core.exceptions import FieldDoesNotExist
from django.db.models import NOT_PROVIDED
from django.utils.functional import cached_property
from .base import Operation
from .utils import field_is_referenced, field_references, get_references
class FieldOperation(Operation):
def __init__(self, model_name, n... |
e5a4b7e355dad8d822c857a9288ef17ba4cf0bb406c37e2fb783ba3ffe6c0349 | import json
from django import forms
from django.core import checks, exceptions
from django.db import NotSupportedError, connections, router
from django.db.models import lookups
from django.db.models.lookups import PostgresOperatorLookup, Transform
from django.utils.translation import gettext_lazy as _
from . import ... |
9cb0344dafbd3c836c0997d2ac6cfa3bcaac197dd4e1dd071ad2269be7dd6a12 | import math
from django.db.models.expressions import Func, Value
from django.db.models.fields import FloatField, IntegerField
from django.db.models.functions import Cast
from django.db.models.functions.mixins import (
FixDecimalInputMixin, NumericOutputFieldMixin,
)
from django.db.models.lookups import Transform
... |
4c5efdcdc73d31ff4b7ec1933d8113627e8edc8948f522878c5a911b28767c28 | 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... |
5339dea5f41734e1e9eaa61933b317b5bfa7d92b3692a7ef88f38d48f9713dfb | """
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 ... |
a6b9422f67145b57ca2569f328bf64f3bab809a588ddb4018e82780430f55a47 | import collections
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, RawSQL, Ref,... |
c21f9ed2c892f7b2f21e9b3532e956d31e23f9b27d2d2be419e421d083329bc4 | from collections import namedtuple
import cx_Oracle
from django.db import models
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo as BaseFieldInfo, TableInfo,
)
from django.utils.functional import cached_property
FieldInfo = namedtuple('FieldInfo', BaseFieldInfo._fields + ... |
4710e94092b1709ae23c97f6b361ee59c386cbc47bc9bffd06479b79bb375b0d | import copy
import datetime
import re
from django.db import DatabaseError
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s"
sql_alter_column_type = "MODIFY %(colu... |
35adaebf8e76e49e652bfbbe39b1b3524c046b73c6cc5abd20e2f2cc9201cf7d | import datetime
import decimal
from importlib import import_module
import sqlparse
from django.conf import settings
from django.db import NotSupportedError, transaction
from django.db.backends import utils
from django.utils import timezone
from django.utils.encoding import force_str
class BaseDatabaseOperations:
... |
3f21f94e92694cdf782b064d4caab585d565f3866f216f489654ae26714813bd | 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... |
002838df306cdcf08050285fb78dc914f12c6d879e1ee9dc9de5e0d68c84c397 | from collections import namedtuple
import sqlparse
from MySQLdb.constants import FIELD_TYPE
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo as BaseFieldInfo, TableInfo,
)
from django.db.models import Index
from django.utils.datastructures import OrderedSet
FieldInfo = nam... |
69622015412796fb9f4d200ca59e059605ff15431aaeca7a063c9ad4fa836b6e | """
MySQL database backend for Django.
Requires mysqlclient: https://pypi.org/project/mysqlclient/
"""
from django.core.exceptions import ImproperlyConfigured
from django.db import IntegrityError
from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper
from dja... |
843cfc0bd3b849396aedad8d030835d39339e8061cffd67aca6cb13fc5c6b7a4 | from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.models import NOT_PROVIDED
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
sql_rename_table = "RENAME TABLE %(old_table)s TO %(new_table)s"
sql_alter_column_null = "MODIFY %(column)s %(type)s NULL"
sql_alter_column_... |
c57509ed6abfc3182dafd2150ab352acd95267852b1e29908b60e6fc9ff7b914 | """
PostgreSQL database backend for Django.
Requires psycopg 2: https://www.psycopg.org/
"""
import asyncio
import threading
import warnings
from contextlib import contextmanager
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError as WrappedDat... |
4c1dd6a19311fcedb906e0eeba703cdcbf28d75eb0b598afbe0080a23d6386ed | import signal
from django.db.backends.base.client import BaseDatabaseClient
class DatabaseClient(BaseDatabaseClient):
executable_name = 'psql'
@classmethod
def settings_to_cmd_args_env(cls, settings_dict, parameters):
args = [cls.executable_name]
options = settings_dict.get('OPTIONS', {}... |
5f87f143a7663b4e9d0626a490e40b924235735d19f77ad68245037b5a85ea81 | import operator
import platform
from django.db import transaction
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.utils import OperationalError
from django.utils.functional import cached_property
from .base import Database
class DatabaseFeatures(BaseDatabaseFeatures):
# SQLite c... |
ff78d4a1ca4bdf89951c8008dc8956181e5d32195a3d92d3181bf1702d7af7d3 | import re
from collections import namedtuple
import sqlparse
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo as BaseFieldInfo, TableInfo,
)
from django.db.models import Index
from django.utils.regex_helper import _lazy_re_compile
FieldInfo = namedtuple('FieldInfo', BaseFi... |
be1181c0908bd1dc25dd8ee9485031b6842719f2e160f02eebd9b60a67e8a8e9 | """
SQLite backend for the sqlite3 module in the standard library.
"""
import datetime
import decimal
import functools
import hashlib
import math
import operator
import random
import re
import statistics
import warnings
from itertools import chain
from sqlite3 import dbapi2 as Database
import pytz
from django.core.ex... |
759a33368063d352900ff57e9029c36c25b0a49ad521c0ea64a9fa7ddff61020 | import datetime
import decimal
import uuid
from functools import lru_cache
from itertools import chain
from django.conf import settings
from django.core.exceptions import FieldError
from django.db import DatabaseError, NotSupportedError, models
from django.db.backends.base.operations import BaseDatabaseOperations
from... |
25e938d80e437678707a0872da7b6a614ccf267694ae83a3f0f737cf4b93eb47 | import copy
from decimal import Decimal
from django.apps.registry import Apps
from django.db import NotSupportedError
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.backends.ddl_references import Statement
from django.db.backends.utils import strip_quotes
from django.db.models impor... |
e212efef977974b3cce18d514cdb93481dcf24cff96e4a275e327a559382607c | from django.db.backends.base.client import BaseDatabaseClient
class DatabaseClient(BaseDatabaseClient):
executable_name = 'sqlite3'
@classmethod
def settings_to_cmd_args_env(cls, settings_dict, parameters):
args = [cls.executable_name, settings_dict['NAME'], *parameters]
return args, None... |
c60e7877724a16b558f1e331405dfe5f94a0fd78fe2deae25cb619b3ac908c4f | import os
import shutil
import sys
from pathlib import Path
from django.db.backends.base.creation import BaseDatabaseCreation
class DatabaseCreation(BaseDatabaseCreation):
@staticmethod
def is_in_memory_db(database_name):
return not isinstance(database_name, Path) and (
database_name == ... |
4ce12274c8d4788b328984acaa81c58f38746ed9de0aa5762126e08cb5cbece9 | import os
from datetime import datetime
from urllib.parse import urljoin
from django.conf import settings
from django.core.exceptions import SuspiciousFileOperation
from django.core.files import File, locks
from django.core.files.move import file_move_safe
from django.core.signals import setting_changed
from django.ut... |
a08d3b8186736f23d5ad5ccd943ae7fdcc40d894f9b629d8170b9b03f5d6598b | from itertools import chain
from django.utils.inspect import func_accepts_kwargs
from django.utils.itercompat import is_iterable
class Tags:
"""
Built-in tags for internal checks.
"""
admin = 'admin'
async_support = 'async_support'
caches = 'caches'
compatibility = 'compatibility'
dat... |
307dd359710b5f28d1c9e0d11b67f7d42d01568f74f1b26c7644221e30206c85 | from .messages import (
CRITICAL, DEBUG, ERROR, INFO, WARNING, CheckMessage, Critical, Debug,
Error, Info, Warning,
)
from .registry import Tags, register, run_checks, tag_exists
# Import these to force registration of checks
import django.core.checks.async_checks # NOQA isort:skip
import django.core.checks.c... |
3916c8b6eb8b54bbab7239be1d30e167efd2b0a278ba8a72c0474e5560c942b7 | # Levels
DEBUG = 10
INFO = 20
WARNING = 30
ERROR = 40
CRITICAL = 50
class CheckMessage:
def __init__(self, level, msg, hint=None, obj=None, id=None):
if not isinstance(level, int):
raise TypeError('The first argument should be level.')
self.level = level
self.msg = msg
... |
8b1cd869690eeda5ed4d87f99171946c9c4e1daffb24158412ca3f2c759e05a6 | import sys
from django.apps import apps
from django.db import models
def sql_flush(style, connection, reset_sequences=True, allow_cascade=False):
"""
Return a list of the SQL statements used to flush the database.
"""
tables = connection.introspection.django_table_names(only_existing=True, include_vi... |
1bd12feda2c2309c59cf29590d4eeec5de3803b3032395896a0dd7d2212935eb | """
Module for abstract serializer/unserializer base classes.
"""
from io import StringIO
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
DEFER_FIELD = object()
class SerializerDoesNotExist(KeyError):
"""The requested serializer was not found."""
pass
class Serialization... |
0e0c601e181bab1b9b3bca8b80d4b23488f949f42431bb4d66f22edb00d6b437 | import mimetypes
from email import (
charset as Charset, encoders as Encoders, generator, message_from_string,
)
from email.errors import HeaderParseError
from email.header import Header
from email.headerregistry import Address, parser
from email.message import Message
from email.mime.base import MIMEBase
from emai... |
1c84d8b4d0ef620fd364713d2c4ffd5e6f161b03622bde14cc2eb0d9c0660d4f | from django.conf import settings
from .. import Error, Tags, register
@register(Tags.compatibility)
def check_csrf_trusted_origins(app_configs, **kwargs):
errors = []
for origin in settings.CSRF_TRUSTED_ORIGINS:
if '://' not in origin:
errors.append(Error(
'As of Django 4.... |
88f955e2921f81d43fe6716966ea15ced0d19dd4b8fdabfe5ac9a17925f6164e | from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from .. import Error, Tags, Warning, register
CROSS_ORIGIN_OPENER_POLICY_VALUES = {
'same-origin', 'same-origin-allow-popups', 'unsafe-none',
}
REFERRER_POLICY_VALUES = {
'no-referrer', 'no-referrer-when-downgrade', 'orig... |
b9113eef895b0a42b8cdf5231c389dd87d8a137bb578abe6505c167948664724 | import sys
import time
from importlib import import_module
from django.apps import apps
from django.core.management.base import (
BaseCommand, CommandError, no_translations,
)
from django.core.management.sql import (
emit_post_migrate_signal, emit_pre_migrate_signal,
)
from django.db import DEFAULT_DB_ALIAS, c... |
91a4a7fba66223f2636d539730042718ff075358e88d2b8c819f9bdbf18be885 | import codecs
import concurrent.futures
import glob
import os
from pathlib import Path
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import (
find_command, is_ignored_path, popen_wrapper,
)
def has_bom(fn):
with fn.open('rb') as f:
sample = f.read... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.