hash
stringlengths
64
64
content
stringlengths
0
1.51M
7576b6ad22f8c78808393e6a729384c2d748906fff67822754e5c6af24ece688
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...
f0270a2ec4fa3bc93edbd4da3c673aa69b7e247caf5f387713ecb662cbb13d1b
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...
7f4cdc686470846d96fa16d4897aaecd1b8405fb4ca3455ef0e4c72992ae1d34
""" Helpers to manipulate deferred DDL statements that might need to be adjusted or discarded within when executing a migration. """ from copy import deepcopy class Reference: """Base class that defines the reference interface.""" def references_table(self, table): """ Return whether or not t...
ba0ae1b74d91e5fe0352f5d854a01182dd617d640d16097f914e3b2ed1e18072
from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.state import ModelState from django.db.models.options import normalize_together from django.utils.functional import cached_property from .fields import ( AddField, AlterField, FieldOperation, RemoveFie...
f8407186c24fb3f26c75f84fd484dd30a11ad4d30d548f03e1a9cddfe746a76f
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...
41fd65186df5ed411be6bd4ff2faec8d318fd2df5a88a20cb0ae844ea1b94de8
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...
c291f76275111fa1d0ea6def6118496798f9e7a2ad00f31991ff5ff744d769a8
""" 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 ...
c46a344f299779bde267a9634021d718c301c542c30cba7d545f5e63e29b2048
""" Oracle database backend for Django. Requires cx_Oracle: https://oracle.github.io/python-cx_Oracle/ """ import datetime import decimal import os import platform from contextlib import contextmanager from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import Integ...
83f33827e7e5f1cf4675ed5c41ae0afa902ec33a692a1168e19605e34c6fe25a
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...
3edfcc43ab667dba87053cd21fba8b4d7fc1bdca5ed65195eb9284ac915576c5
import datetime from .base import Database class InsertVar: """ A late-binding cursor variable that can be passed to Cursor.execute as a parameter, in order to receive the id of the row created by an insert statement. """ types = { 'AutoField': int, 'BigAutoField': int, ...
59f775aaeda31827d667ad73f8d96346dce49883a25d37daeec96fc449abdc34
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...
1b7b35fb79f030925d1f6203574afa1bcbe2cee2112aac4438805074ad2a4c00
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...
3bb7e44ee6dcf63167c714a9e16c5968f6717b9c79b29522b9a1c63a4027faff
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...
ed2c265ca500b499b15d55c7a21c37b6ee05e98db304a7b04479c76dac2512d4
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...
8c75ee312d427cddd7460be678f31d8a4e01aeeae98378d178466355e3058073
""" 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...
77bf53437dcc855db987b3b75a48dae51bbcd72dafa111454f164f8c3fdcf68a
import uuid from django.conf import settings from django.db.backends.base.operations import BaseDatabaseOperations from django.utils import timezone from django.utils.encoding import force_str class DatabaseOperations(BaseDatabaseOperations): compiler_module = "django.db.backends.mysql.compiler" # MySQL sto...
ba3681947ff4ae91f56d6a47123bd077decf4da5959affc41ce0bc4adfd9764d
""" 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...
be5f5a5982cc223a664d74c0313e2bfa8c83d14a8caee32e4578e7151e4d5468
import psycopg2 from django.db.backends.base.schema import BaseDatabaseSchemaEditor from django.db.backends.ddl_references import IndexColumns from django.db.backends.utils import strip_quotes class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_create_sequence = "CREATE SEQUENCE %(sequence)s" sql_dele...
ac32aabe0f509dbde79019c18a8213912e8b13fda6acc594a6ba1f7a267cfccd
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...
ad4d25cfa264090fef8447c0d6b8ac808dd5bcadc9b4173a911167e7aa0bcb8b
""" 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...
1d837a13934598a1420d33a6765be6ef4eba981dc3aa8741167621598616aae1
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...
9c0c817fdaafbc400a5e22b95887770aa13705230e5f12ee6b448f1fd144fe65
""" HTTP server that implements the Python WSGI protocol (PEP 333, rev 1.21). Based on wsgiref.simple_server which is part of the standard library since 2.5. This is a simple server for use in testing or debugging Django apps. It hasn't been reviewed for security issues. DON'T USE IT FOR PRODUCTION USE! """ import l...
8ed18e83a13fc2170e17a9e649fab1e22aa47b498f60ed4a0f40dce9ae193686
import asyncio import logging import types from asgiref.sync import async_to_sync, sync_to_async from django.conf import settings from django.core.exceptions import ImproperlyConfigured, MiddlewareNotUsed from django.core.signals import request_finished from django.db import connections, transaction from django.urls ...
cc50099ee221f2b4eb368d4074652df20c30eaa2a405915343b70ee84616e1a8
from django.conf import settings from django.core.exceptions import ImproperlyConfigured from .. import Error, Tags, Warning, register REFERRER_POLICY_VALUES = { 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'same-origin', 'strict-origin', 'strict-origin-when-cross-ori...
38a7c95befe091ba58f441a68079c4fae0ee9f3cecafe2494bacf350af00879d
import inspect from django.conf import settings from .. import Error, Tags, Warning, register W003 = Warning( "You don't appear to be using Django's built-in " "cross-site request forgery protection via the middleware " "('django.middleware.csrf.CsrfViewMiddleware' is not in your " "MIDDLEWARE). Enab...
8c879e1e9de35e67fc761a22142c77009e0e0f62b482c836d57a9908ff808699
import gzip import os import warnings from django.apps import apps from django.core import serializers from django.core.management.base import BaseCommand, CommandError from django.core.management.utils import parse_apps_and_model_labels from django.db import DEFAULT_DB_ALIAS, router try: import bz2 has_bz2 =...
cc51184deb2800af4f079ec996db600a0c21a4e35f0d5d864cd30d0487ce5081
import functools import glob import gzip import os import sys import warnings import zipfile from itertools import product from django.apps import apps from django.conf import settings from django.core import serializers from django.core.exceptions import ImproperlyConfigured from django.core.management.base import Ba...
e201a26274f1a8c036c7e97d93e4bde30b8a3d79d46a6057d8176ca0120b5e48
import glob import os import re import sys from functools import total_ordering from itertools import dropwhile import django from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.temp import NamedTemporaryFile from django.core.management.base import BaseComman...
6b4abdb65d2d4f23d54a89e6094dae9ca096250fc08d678ed8e711e934ecf530
from django.db import NotSupportedError from django.db.models import Func, Index from django.utils.functional import cached_property __all__ = [ 'BloomIndex', 'BrinIndex', 'BTreeIndex', 'GinIndex', 'GistIndex', 'HashIndex', 'SpGistIndex', ] class PostgresIndex(Index): @cached_property def max_name_l...
a5b7a544bb1d943f4e78247295cc535540a5aea06912708e7416bd44a28df563
from psycopg2.extras import ( DateRange, DateTimeRange, DateTimeTZRange, NumericRange, ) from django.apps import AppConfig from django.db import connections from django.db.backends.signals import connection_created from django.db.migrations.writer import MigrationWriter from django.db.models import CharField, Orde...
d2fe7c141501a18b2e52e7a95bf7c11008cb60444033fdfc3e4245ad5392df93
from django.apps import apps from django.conf import settings from django.contrib.redirects.models import Redirect from django.contrib.sites.shortcuts import get_current_site from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponseGone, HttpResponsePermanentRedirect from django.utils...
08e3f3bcbf6d708b9f4e90bce4505cdd726003bfcb7cfd11047b4531d4cb5e43
import inspect import re from django.apps import apps as django_apps from django.conf import settings from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.middleware.csrf import rotate_token from django.utils.crypto import constant_time_compare from django.utils.module_loading import i...
dfed7fc20b9a4ad732de127e9cf3b226287ad8f61a69cea2d45c1ed4bb9eb90c
from datetime import datetime from django.conf import settings from django.utils.crypto import constant_time_compare, salted_hmac from django.utils.http import base36_to_int, int_to_base36 class PasswordResetTokenGenerator: """ Strategy object used to generate and check tokens for the password reset mech...
9b81c57ba89acea72bd2b060d99b30bdecb7a5c5bec2121ba2bc79a3bd99221b
import base64 import binascii import functools import hashlib import importlib import math import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.signals import setting_changed from django.dispatch import receiver from django.utils.crypto import ( ...
21a2e86ac73f59cec737bf1a0ad3a9992677b311d1753231b892bd8847a647cf
""" This module allows importing AbstractBaseUser even when django.contrib.auth is not in INSTALLED_APPS. """ import unicodedata from django.contrib.auth import password_validation from django.contrib.auth.hashers import ( check_password, is_password_usable, make_password, ) from django.db import models from djang...
489569a4d34222bb0950757bb198e3ad5a95a872af19148ab38b0c9b8c1bfcde
def action(function=None, *, permissions=None, description=None): """ Conveniently add attributes to an action function:: @admin.action( permissions=['publish'], description='Mark selected stories as published', ) def make_published(self, request, queryset): ...
5c09e1af3f393ecc09c79a95a24ea52ef464350bdd50f137f5411e416977b49b
from django.contrib.admin.decorators import action, display, register from django.contrib.admin.filters import ( AllValuesFieldListFilter, BooleanFieldListFilter, ChoicesFieldListFilter, DateFieldListFilter, EmptyFieldListFilter, FieldListFilter, ListFilter, RelatedFieldListFilter, RelatedOnlyFieldListFilte...
8ff9813af7e6cccb61da084acca8164f60d71b5cb195b0c7aa70104605b9ae58
import copy import json import operator import re from functools import partial, reduce, update_wrapper from urllib.parse import quote as urlquote from django import forms from django.conf import settings from django.contrib import messages from django.contrib.admin import helpers, widgets from django.contrib.admin.ch...
2d8f324279666b5807635d5bfc3047b24404bb53544de2521fa1aa5109e641d8
import re from functools import update_wrapper from weakref import WeakSet from django.apps import apps from django.conf import settings from django.contrib.admin import ModelAdmin, actions from django.contrib.admin.views.autocomplete import AutocompleteJsonView from django.contrib.auth import REDIRECT_FIELD_NAME from...
3da85fea2a48ddc95a8eb98a1fb9eae9a5afddba5389ce0d8282fc70f315ad7c
""" Built-in, globally-available admin actions. """ from django.contrib import messages from django.contrib.admin import helpers from django.contrib.admin.decorators import action from django.contrib.admin.utils import model_ngettext from django.core.exceptions import PermissionDenied from django.template.response imp...
125ba2f216ce4f191ad216ca03fe9c1e77fe21f050f4a4f333995a7eb0550842
""" Form Widget classes specific to the Django admin site. """ import copy import json from django import forms from django.conf import settings from django.core.exceptions import ValidationError from django.core.validators import URLValidator from django.db.models import CASCADE from django.urls import reverse from d...
7ca268c4a3ba06d29b47f2223116d4fde26219649e743630c8236084020353ce
from functools import partial from django.contrib.admin.checks import InlineModelAdminChecks from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.forms import ( BaseGenericInlineFormSet, generi...
5cd9bfe76a8a13602aa2d9422d3d131d1c683b896e6946f80deb71aee121afa3
import functools import itertools import operator from collections import defaultdict from django.contrib.contenttypes.models import ContentType from django.core import checks from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, models, router, transaction fr...
0307417b2c1c682051c9c437fd4d6a0b38969c746da8781cc4bea75ec392389d
import time from importlib import import_module from django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.contrib.sessions.exceptions import SessionInterrupted from django.utils.cache import patch_vary_headers from django.utils.deprecation import MiddlewareMixin from dj...
f1141b92e85442383a9af8cad7b5d42d8c792f05c65a4c9d33b124123d31b1d4
# Copyright (c) 2007, Robert Coup <robert.coup@onetrackmind.co.nz> # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, #...
b138b71b773c9fb11c19acb5f70b001b01d820bb2b609445b520ab247d5e9b52
import json from django.conf import settings from django.contrib.messages.storage.base import BaseStorage, Message from django.core import signing from django.http import SimpleCookie from django.utils.safestring import SafeData, mark_safe class MessageEncoder(json.JSONEncoder): """ Compactly serialize insta...
e6e871d99975a8bfb1f8b928a07aecb6eebf93746d2f3fb011e1ba0048f49a39
from django.db.models import JSONField as BuiltinJSONField __all__ = ['JSONField'] class JSONField(BuiltinJSONField): system_check_removed_details = { 'msg': ( 'django.contrib.postgres.fields.JSONField is removed except for ' 'support in historical migrations.' ), ...
36310d9f6f82e817171f84fc61e0b42b601b0e4f0c553f2da5aacbdd0e0e17a8
from .array import * # NOQA from .hstore import * # NOQA from .ranges import * # NOQA
c08f745410d9518a620ebf34baf6a4a6fb789ee94cde6f6e6e78379136a72663
from django.apps import apps from django.core.exceptions import FieldDoesNotExist, PermissionDenied from django.http import Http404, JsonResponse from django.views.generic.list import BaseListView class AutocompleteJsonView(BaseListView): """Handle AutocompleteWidget's AJAX requests for data.""" paginate_by =...
c38a7fa9cd5bc2286442bf7aaca56e669479229da3205610c9cde1bb0cbfcc2c
import logging import string from datetime import datetime, timedelta from django.conf import settings from django.core import signing from django.utils import timezone from django.utils.crypto import get_random_string from django.utils.module_loading import import_string # session_key should not be case sensitive be...
314662f6c2a27dc46af7fe96b060fd09b1ac7415ba230485b7e35b6b445a12ec
from importlib import import_module from django.conf import settings from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): help = ( "Can be run as a cronjob or directly to clean out expired sessions " "(only with the database backend at the moment)." ) ...
e9901996485632e2bed03875e6c2a8a4b442cfdbf6136f366af591e268b0de4b
import re from django.contrib.gis.db import models class BaseSpatialFeatures: gis_enabled = True # Does the database contain a SpatialRefSys model to store SRID information? has_spatialrefsys_table = True # Does the backend support the django.contrib.gis.utils.add_srs_entry() utility? supports_...
804b0f40c4f8f4fea739987c6c26db3ad768a2c2e82af8a8601263d53b8b9ed8
from django.contrib.gis.db.models import GeometryField from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.measure import ( Area as AreaMeasure, Distance as DistanceMeasure, ) from django.db import NotSupportedError from django.utils.functional import cached_property class BaseSpat...
62ff15ec5acc08b2d3fd4ae2ec9ea25d620e8067a5bf8b54cc2036e8b8808657
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures from django.db.backends.mysql.features import ( DatabaseFeatures as MySQLDatabaseFeatures, ) from django.utils.functional import cached_property class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): has_spatialrefsys_ta...
1a67b2967d818f18c56d7600b1700d5d9507e40de7383f4940811143aa51bc7f
from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.geos.geometry import GEOSGeometry...
1ae046ecde7fcd4bb27f8f5920e2cc23403141c89431abf90355710265a50ae9
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures from django.db.backends.postgresql.features import ( DatabaseFeatures as Psycopg2DatabaseFeatures, ) class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): supports_geography = True supports_3d_storage = True ...
ea5869fc399e3e2d89c7ffef0a2853c8e2e0446d6fbca5190cadc2dfc16bb5c5
import compileall import os from importlib import import_module from django.db import connection, connections from django.db.migrations.exceptions import ( AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, ) from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder i...
60a6e341735116dadd8ef703ee180d54ffcd0d27b000c736ab54b5c4111ce5f9
from django.core.exceptions import FieldDoesNotExist from django.db import ( IntegrityError, connection, migrations, models, transaction, ) from django.db.migrations.migration import Migration from django.db.migrations.operations.fields import FieldOperation from django.db.migrations.state import ModelState, Projec...
b7647739231afedec9a687449f17835826cbed91f3a2a43357a1af7cfa000da7
import os import shutil import tempfile from contextlib import contextmanager from importlib import import_module from django.apps import apps from django.db import connection, connections, migrations, models from django.db.migrations.migration import Migration from django.db.migrations.recorder import MigrationRecord...
1a9eb40d0fb67223f128fa8518afc04282ec8b18a117282d256946a6f38e1c53
import gzip import os import sys import tempfile import unittest import warnings from io import StringIO from unittest import mock from django.apps import apps from django.contrib.sites.models import Site from django.core import management from django.core.files.temp import NamedTemporaryFile from django.core.manageme...
6793e53719b646142c06f195f8cb4329073bd07cda6cd564bf0c212070f226de
from unittest import TestCase from django.core.exceptions import ValidationError from django.db import models class ValidationMessagesTest(TestCase): def _test_validation_messages(self, field, value, expected): with self.assertRaises(ValidationError) as cm: field.clean(value, None) s...
5aed8fdf91f869ee211fe870582db4cb31dd4d47e3ae35f27b4e67391e51c61b
import os import sys import unittest from types import ModuleType, SimpleNamespace from unittest import mock from django.conf import ENVIRONMENT_VARIABLE, LazySettings, Settings, settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import ( SimpleTes...
2f4f2cd3dc74e09886fe7bd50d3cdfb005dc5ecb4197411d45a1c7953b2fab7b
import datetime import itertools import re from importlib import import_module from unittest import mock from urllib.parse import quote, urljoin from django.apps import apps from django.conf import settings from django.contrib.admin.models import LogEntry from django.contrib.auth import ( BACKEND_SESSION_KEY, REDI...
e622030092d1dfe41b3af96f032ae195475f6dff8fbe2a5ad0af31b522a7b7fc
from datetime import datetime, timedelta from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase from .models import CustomEmailField class MockedPasswordResetTokenGenerator(PasswordResetTokenGen...
8f2f122db581e549816d8efc82ff0fb4ec99b6c2cc8d75d5eecfdc5c6229c361
from unittest import mock, skipUnless from django.conf.global_settings import PASSWORD_HASHERS from django.contrib.auth.hashers import ( UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH, BasePasswordHasher, BCryptPasswordHasher, BCryptSHA256PasswordHasher, PBKDF2PasswordHasher, PBKDF2SHA1PasswordH...
1011342a6a546c90b529c9d2b20d20731febde66aba43339a2bc901b3ecc4f48
from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.models import User from django.http import HttpRequest, HttpResponse from django.test import TestCase class TestAuthenticationMiddleware(TestCase): @classmethod def setUpTestData(cls): cls.user = User.objects....
5ba3c15d80cbfa4f861fa07b7adbf86754dd2fb53af27513830bebeabacdbdc9
import string import uuid from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings from django.urls import NoReverseMatch, Resolver404, path, resolve, reverse from .converters import DynamicConverter from .views import empty_view i...
3ba86f90fd53f2b3b3fd4b147ec312b087d4fe89d55f2fa9ed115e971bbdecbf
from django.apps import apps from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.core.exceptions import FieldDoesNotExist from django.db.models import ( CharField, Field, ForeignObjectRel, ManyToManyField, ) from django.db.models.options import EMPTY_RELATION_TREE,...
e4168b7bf2b811d2711aa82d08442faedbf20d51d323881a6b68fbaf8dc843d3
from .models import ( AbstractPerson, BasePerson, Person, ProxyPerson, Relating, Relation, ) TEST_RESULTS = { 'get_all_field_names': { Person: [ 'baseperson_ptr', 'baseperson_ptr_id', 'content_type_abstract', 'content_type_abstract_id', 'conte...
f8eb5e7447c44583e0fe7d31525adc7d261b34cc8476ed8724ffa365facbecf5
import datetime import os import re import unittest from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse import pytz from django.contrib import admin from django.contrib.admin import AdminSite, ModelAdmin from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admi...
9df69c9832b781d01ef48ade51f948f628648f6def01e0016408c389bf3794c0
import datetime import os import tempfile import uuid from django.contrib import admin from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.core.exceptions import Val...
c8ff80c085af99f060654b9d5494134920f07fc641393b7dc91be16ff9da4f38
import datetime import os import tempfile from io import StringIO from wsgiref.util import FileWrapper from django import forms from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter from django.contrib.admin.views.main import ChangeList from django.contrib.auth.admin import GroupAdmi...
c974ec779d655144156f2c062d4bbd313eb2c96ba775c7f2f7d6b043820f869f
from django.http import HttpResponse from django.urls import include, path from . import admin, custom_has_permission_admin, customadmin, views from .test_autocomplete_view import site as autocomplete_site def non_admin_view(request): return HttpResponse() urlpatterns = [ path('test_admin/admin/doc/', incl...
30fcc615e5735c38a7c56a404dcb8872412074add858943cf4c62ab371265a3b
import json from contextlib import contextmanager from django.contrib import admin from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.admin.views.autocomplete import AutocompleteJsonView from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import...
078a937423718461bc256fd307337b7b5313c4e4dc642e1d5e3109008ec51cea
import datetime import sys import unittest from django.contrib.admin import ( AllValuesFieldListFilter, BooleanFieldListFilter, EmptyFieldListFilter, ModelAdmin, RelatedOnlyFieldListFilter, SimpleListFilter, site, ) from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.auth.adm...
4dce0105b269104b80952da55cde06ac1887879d1b4ada798e9122f35f90c8ab
from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models class Book(models.Model): title = models.CharField(max_length=50) year = models.Positiv...
475f0713d2a9fe1160b8c1bf21fefb6ea7cfc1ae4a099d43f73fbd6cd90b7931
import datetime from django.core import signing from django.test import SimpleTestCase from django.test.utils import freeze_time from django.utils.crypto import InvalidAlgorithm class TestSigner(SimpleTestCase): def test_signature(self): "signature() method should generate a signature" signer = ...
c8ac33d6f1530ac54f57449f3e994d43638a76f410c55ef9754a638c46b3c531
from django.conf import settings from django.core.exceptions import MiddlewareNotUsed from django.http import HttpResponse from django.test import RequestFactory, SimpleTestCase, override_settings from . import middleware as mw @override_settings(ROOT_URLCONF='middleware_exceptions.urls') class MiddlewareTests(Simpl...
504edabcedc7aff9b07c6bca90d030792fcb22d7d314f42c16eac190a40103ac
""" Indirection layer for PostgreSQL-specific fields, so the tests don't fail when run with a backend other than PostgreSQL. """ import enum from django.db import models try: from django.contrib.postgres.fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, Date...
31529dc1b65a9ca83c0d7cfeb1e33bdcddf0b168a70f7c6b3e277bb5d0e2e937
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,...
53d20aafea18b828bb1dde0edd70e47c31a87a25d13dd6127ecbdf28e977f6a3
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db.models import ( BooleanField, Case, CharField, Count, DateTimeField, DecimalField, Exists, ExpressionWrapper, F, FloatField, Func, IntegerField, Max, OuterRef, Q, Subquery, Sum, Value...
5bc6087f0177952d618ccd2782c827174a3e04af6396db68962cb00e44989b90
import json import random from django.conf import settings from django.contrib.messages import constants from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.cookie import ( CookieStorage, MessageDecoder, MessageEncoder, ) from django.core.signing import get_cookie_signer f...
53b113aa79d7ef1e82a0d5ad4e45f935174792ddb70b4636eb28e664999faed3
import random from django.contrib.messages import constants from django.contrib.messages.storage.fallback import ( CookieStorage, FallbackStorage, ) from django.test import SimpleTestCase from django.utils.crypto import get_random_string from .base import BaseTests from .test_cookie import set_cookie_data, stored...
d257cdbdd087f85d709a4478a06db7279c92bdeba638a9e19c8b0fab3284e55e
from django.core.signing import b64_decode from django.test import SimpleTestCase, override_settings from django.urls import reverse from .urls import ContactFormViewWithMsg @override_settings(ROOT_URLCONF='messages_tests.urls') class SuccessMessageMixinTests(SimpleTestCase): def test_set_messages_success(self)...
df8163999e9d95da2c8c7774e6a8023f9a155fc29ef754cf5ab295a40cd51b82
import unittest from datetime import date, datetime, time, timedelta from decimal import Decimal from operator import attrgetter, itemgetter from uuid import UUID from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( BinaryField, BooleanField, Case, Count, De...
62699aff050a922e2c5d5779ad208c9ed12a333d80ff67c5311708e7907b2297
from django.db import models try: from PIL import Image except ImportError: Image = None class CaseTestModel(models.Model): integer = models.IntegerField() integer2 = models.IntegerField(null=True) string = models.CharField(max_length=100, default='') big_integer = models.BigIntegerField(nul...
72e7ede121ac60e642d34f5791bb04f09a4ca5c248635dfbdc226735799d0bcd
from django.apps import apps from django.db import models from django.test import SimpleTestCase, override_settings from django.test.utils import isolate_lru_cache class FieldDeconstructionTests(SimpleTestCase): """ Tests the deconstruct() method on all core fields. """ def test_name(self): "...
fb827d9bf123c1f99489d57f344dbaf933c92eeda3fb9c470c64412b901c8e8b
import contextlib import os import py_compile import shutil import sys import tempfile import threading import time import types import weakref import zipfile from importlib import import_module from pathlib import Path from subprocess import CompletedProcess from unittest import mock, skip, skipIf import pytz import...
b324f81c19a06368c4e1c313178c952a09eda60204243b605ee804f6b4a7f0dc
import platform import unittest from datetime import datetime from unittest import mock from django.test import SimpleTestCase from django.utils.datastructures import MultiValueDict from django.utils.http import ( base36_to_int, escape_leading_slashes, http_date, int_to_base36, is_same_domain, parse_etags, par...
948c27b3bde4b7390505c7976d522b77bc038c62c3533e62b8bf10db8c97571f
import json import sys from django.test import SimpleTestCase from django.utils import text from django.utils.functional import lazystr from django.utils.text import format_lazy from django.utils.translation import gettext_lazy, override IS_WIDE_BUILD = (len('\U0001F4A9') == 1) class TestUtilsText(SimpleTestCase): ...
29dbc2b7749656d712e529e1304979b3adeafc266d7773ddc91de494aae154db
from unittest import mock from django.conf import settings from django.db import connection, models from django.db.models.functions import Lower, Upper from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test.utils import isolate_apps from .models import Book, ChildModel1, ChildModel2 ...
47c99f264f809f93367362a711f42713aa5fff7af376c8541a5654aaa87d87d5
""" A test spanning all the capabilities of all the serializers. This class defines sample data and a dynamically generated test case that is capable of testing the capabilities of the serializers. This includes all valid data values, plus forward, backwards and self references. """ import datetime import decimal impo...
6c07c12a424968bc0d105c878291e9e6ab53a8f83fa988e12c576066f42c9300
from django.contrib import admin from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import TestCase from .models import Band class AdminActionsTests(TestCase): @classmethod def setUpTestData(cls): cls.superuser = User.o...
3894207e124dee0d464294d2d0d46a0ce3ebddffc57fcf3808b4c36bf49ffd0c
from django import forms from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter, SimpleListFilter from django.contrib.admin.options import VERTICAL, ModelAdmin, TabularInline from django.contrib.admin.sites import AdminSite from django.core.checks import Error from django.db.models imp...
8f429d71251454a3a84633316ab7f1ec8db2c79e6e8440b23fcee6858969329d
from datetime import datetime from decimal import Decimal from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import helpers from django.contrib.admin.utils import ( NestedObjects, display_for_field, display_for_value, flatten, flatten_fieldsets,...
f311cb5789f3237322cfda8782054c7e05d5fb8fdb6f6f41123d311156208110
from django.contrib import admin from django.db import models from django.utils.translation import gettext_lazy as _ class Site(models.Model): domain = models.CharField(max_length=100) def __str__(self): return self.domain class Article(models.Model): """ A simple Article model for testing ...
c392ff2abc5de74bbbd78b5db771e8f7e0355a423961d07830e2f905895d179a
import datetime import pickle import sys import unittest from operator import attrgetter from threading import Lock from django.core.exceptions import EmptyResultSet, FieldError from django.db import DEFAULT_DB_ALIAS, connection from django.db.models import Count, Exists, F, OuterRef, Q from django.db.models.expressio...
d5c1d6b2dc842d9aae6b3cfe6f5ef5c73e83c7a1f19945eb5c21fbb2f35e826f
from django.template import Context, Engine from django.template.base import TextNode, VariableNode from django.test import SimpleTestCase class NodelistTest(SimpleTestCase): @classmethod def setUpClass(cls): cls.engine = Engine() super().setUpClass() def test_for(self): template...
c394b0157adfa5991313e9c276dacf1e381e2d4966eadb5a8e1bcf65de24b580
import datetime from unittest import skipUnless from django.db import connection from django.db.models import CASCADE, ForeignKey, Index, Q from django.db.models.functions import Lower from django.test import ( TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature, ) from django.test.utils import ove...
d55b2498dcb4de01c4c719852eca8b8f7f6c144c0f6847d058474e4f507c60e6
from django.contrib.sessions.backends.base import SessionBase class SessionStore(SessionBase): """Session store without support for clearing expired sessions.""" pass