hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
ca7f9b10c4608e0209b6fd664a31779dcf6320e1fda41bd1af7b4ab2a6b97e37 | import ctypes
import itertools
import json
import pickle
import random
from binascii import a2b_hex
from io import BytesIO
from unittest import mock, skipIf
from django.contrib.gis import gdal
from django.contrib.gis.geos import (
GeometryCollection, GEOSException, GEOSGeometry, LinearRing, LineString,
MultiLi... |
21ea2a386fd56fb83be91b4d1db36758e45e3034e651af9310aedde13b714e9f | import os
import shutil
import struct
import tempfile
from django.contrib.gis.gdal import GDAL_VERSION, GDALRaster
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.raster.band import GDALBand
from django.contrib.gis.shortcuts import numpy
from django.test import SimpleTestCase
from... |
1669c759b11caff1cef4db63b3bced7715b22f34b7a4dd100f7ea09669b259cf | import unittest
from django.contrib.gis.gdal import (
GDAL_VERSION, gdal_full_version, gdal_version,
)
class GDALTest(unittest.TestCase):
def test_gdal_version(self):
if GDAL_VERSION:
self.assertEqual(gdal_version(), ('%s.%s.%s' % GDAL_VERSION).encode())
else:
self.ass... |
f52293ee60023c8ffc2085bb284fc94056d546d96ea4dbe0204014fcda68596d | from django.contrib.gis.db import models
from django.db import migrations
from django.db.models import deletion
class Migration(migrations.Migration):
dependencies = [
('rasterapp', '0001_setup_extensions'),
]
operations = [
migrations.CreateModel(
name='RasterModel',
... |
aa43783ec8f9b81ff18d829798e4f7b6f31c98f6243c4a313c630b87477d943e | from django.db import connection, migrations
if connection.features.supports_raster:
from django.contrib.postgres.operations import CreateExtension
pg_version = connection.ops.postgis_version_tuple()
class Migration(migrations.Migration):
# PostGIS 3+ requires postgis_raster extension.
if... |
636f6dab06f27747c3e0cd141341c2f0807d5c4e811644aa2b63c6db608919dd | from django.contrib.gis.db import models
from django.db import connection, migrations
ops = [
migrations.CreateModel(
name='Neighborhood',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(ma... |
e234acc6b33ec28cc1f9c3a1a63579a8629abb7af03065a8e7ec523dba50ba46 | from django.db import models
from django.db.models.fields.related import ReverseManyToOneDescriptor
from django.db.models.lookups import StartsWith
from django.db.models.query_utils import PathInfo
class CustomForeignObjectRel(models.ForeignObjectRel):
"""
Define some extra Field methods so this Rel acts more... |
e4264a6767a1849d6138f9557ab93f41cfe926e65c4c80ccf5f5ac852a0cd0a3 | from django.db import models
class Address(models.Model):
company = models.CharField(max_length=1)
customer_id = models.IntegerField()
class Meta:
unique_together = [
('company', 'customer_id'),
]
class Customer(models.Model):
company = models.CharField(max_length=1)
... |
b3e48110ea22eaef134aaca8a4fd3b20fb8d989bbac5511cc01f81d9cb6b7e65 | import unittest
from django.db import NotSupportedError, connection
from django.db.models import CharField
from django.db.models.functions import SHA224
from django.test import TestCase
from django.test.utils import register_lookup
from ..models import Author
class SHA224Tests(TestCase):
@classmethod
def se... |
446e193a1062534e618772d573e9096fa3736f715f9631e2297c9dad61c3757a | import datetime
import decimal
import unittest
from django.db import connection, models
from django.db.models.functions import Cast
from django.test import (
TestCase, ignore_warnings, override_settings, skipUnlessDBFeature,
)
from ..models import Author, DTModel, Fan, FloatModel
class CastTests(TestCase):
... |
4b173b504fdac97cdac17b6e133273082c713a81e8a70d3e0feae93ccd39f381 | import os
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.middleware.locale import LocaleMiddleware
from django.template import Context, Template
from django.test import SimpleTestCase, override_set... |
46db07ee55d83f3354ca635a3d686615e4f3f025cf9fe9ee1f404ebff12c220c | """
Sphinx plugins for Django documentation.
"""
import json
import os
import re
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList
from sphinx import addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives.code import CodeBlo... |
af07033a6e5b3000b436fe9e9af8118f4deff790d5f0d6f6fbe6967086ec4e67 | """
Django's standard crypto functions and utilities.
"""
import hashlib
import hmac
import secrets
from django.conf import settings
from django.utils.encoding import force_bytes
def salted_hmac(key_salt, value, secret=None):
"""
Return the HMAC-SHA1 of 'value', using a key generated from key_salt and a
... |
96ac7afbdcca9dde6e22581d79134b86a73e8b86df0e962449407bc22943eaf4 | import copy
import inspect
import warnings
from functools import partialmethod
from itertools import chain
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldDoesNotExist, FieldError, MultipleObjectsReturned,
... |
ba6d73c9db82894254d367316706c6ef71902565ee3c3f91dda374eb06111e38 | 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... |
e6d8d7ea25a0d9dcb1d602559ee9facfdbc73c4e2e24e404ea310745ed21ff49 | """
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 ... |
fc12a0f430e732180bc48fb1cdc935c9e954d417652ec6c51eb8937482010b43 | import datetime
import re
from decimal import Decimal
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models import (
Avg, Count, DecimalField, DurationField, F, FloatField, Func, IntegerField,
Max, Min, Sum, Value,
)
from django.db.models.expressions import Case, ... |
e57243382de226d654774a4e6d509d2859bb2bc6b8ae0e1a2eba446ddcc4f258 | import hashlib
import unittest
from django.utils.crypto import constant_time_compare, pbkdf2, salted_hmac
class TestUtilsCryptoMisc(unittest.TestCase):
def test_constant_time_compare(self):
# It's hard to test for constant time, just test the result.
self.assertTrue(constant_time_compare(b'spam'... |
182d87d8c3d1e9b3f6d07af46a96c3cbdccdcb689f0a9b58cfea5c0c7c41455c | # 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... |
f236a926996d85bdc3f1a6bd74cc5c3423249f15846ce840cab2449c085ed34a | import itertools
import json
import os
import re
from urllib.parse import unquote
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.fo... |
389d23d4bbb32c06246800ebc52ae3ad45f169b9e75dcc5a0d113b96858f6968 | import functools
import re
import sys
import types
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 django.urls import re... |
bdb602803296753482ab9fc0858cddc824003f503d7a021b9cee6f3bb40439f1 | """
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
####... |
6b24a93e241a2c36ea1f295c69eaf28532a7ed128f432a71ca4b04e9543466bb | """
Django's standard crypto functions and utilities.
"""
import hashlib
import hmac
import secrets
from django.conf import settings
from django.utils.encoding import force_bytes
class InvalidAlgorithm(ValueError):
"""Algorithm is not supported by hashlib."""
pass
def salted_hmac(key_salt, value, secret=No... |
2cb6e5be6a8722d5b5937f20ab106c14614e66ec61fc7d8c02b4377ed4cf8e10 | 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... |
640ffcc58a109d093e04a5f79e5f7d796c5598251fbf052cde3839f7d1fe17ae | """
Cache middleware. If enabled, each Django-powered page will be cached based on
URL. The canonical way to enable cache middleware is to set
``UpdateCacheMiddleware`` as your first piece of middleware, and
``FetchFromCacheMiddleware`` as the last::
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddl... |
aee95948cea4df4e4f9f002f9b4b9aaafcd785e41af30bf45ca23eaf2c2f0d38 | """
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... |
48271e76e1816ba6d648179b9b380b4fcd8b10218c5d3aad8c93f5c694fbe922 | """
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 impor... |
af54e0f50eb1ca5c50ad4927c17452747a6f5713b34091e40ce43b65751f4be2 | import copy
from contextlib import contextmanager
from django.apps import AppConfig
from django.apps.registry import Apps, apps as global_apps
from django.conf import settings
from django.db import models
from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT
from django.db.models.options import D... |
8dc9d01148bfd0cae0a98a1a253c3d2aee549084d3e669985699f3a1ac0369e1 | 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... |
6c14753855e094a5823ad4ad27d718e48ee2d94022cb146ab7c871dd793d0687 | from django.apps.registry import Apps
from django.db import DatabaseError, models
from django.utils.functional import classproperty
from django.utils.timezone import now
from .exceptions import MigrationSchemaMissing
class MigrationRecorder:
"""
Deal with storing migration records in the database.
Becau... |
09a188815137f903eeba0ada38d3e0d6cef8dafe98769b27f6709b4f53706e6d | """
The main QuerySet implementation. This provides the public API for the ORM.
"""
import copy
import operator
import warnings
from collections import namedtuple
from functools import lru_cache
from itertools import chain
from django.conf import settings
from django.core import exceptions
from django.db import (
... |
d752ab469825a4e9e4ce22b6a8e2eea8066a2a90aea58c47110cef2fd8a4b962 | from django.core.exceptions import ObjectDoesNotExist
from django.db.models import signals
from django.db.models.aggregates import * # NOQA
from django.db.models.aggregates import __all__ as aggregates_all
from django.db.models.constraints import * # NOQA
from django.db.models.constraints import __all__ as constraint... |
a00946b4b6e2b8cabd468a6e38ad4facc3d3fceec00473b17d77150daf88c54d | import bisect
import copy
import inspect
from collections import defaultdict
from django.apps import apps
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
from django.db import connections
from django.db.models import AutoField, Manager, OrderWrt
from django.db.models.query_utils i... |
9cb33f79e07896bff6f92b1c363d7122f4779b9f93bce31f9d4abc11d4950bff | import copy
import inspect
import warnings
from functools import partialmethod
from itertools import chain
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldDoesNotExist, FieldError, MultipleObjectsReturned,
... |
3d51819de4b9de38b57e01fb1e14d74a7ff1389305527be3a4b56ab063443b99 | import copy
import datetime
import inspect
from decimal import Decimal
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import NotSupportedError, connection
from django.db.models import fields
from django.db.models.query_utils import Q
from django.utils.deconstruct import deconstructible
fr... |
60889b0b4b94ec745a64027516e9f1c4ed8021c3d912f2f519a4374a08865155 | import operator
from collections import Counter, defaultdict
from functools import partial, reduce
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):
... |
ddfbdcca90430f44cee3604e2e133c4a84812d3e5af40e87cc56b815409b33fb | 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.... |
657e863e681014467806fabdedf825fb9a90ad7a7b1a3de08f60e046d5c1c06f | 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 (
ModelTuple, field_references_model, is_referenced_by_foreign_key,
)
class FieldOperation(Operation):
def __init__... |
2e75b24c6fc9383d40a071b5f6dce939b896411935c3dcff274995940ce8ebef | import functools
import inspect
from functools import partial
from django import forms
from django.apps import apps
from django.conf import SettingsReference
from django.core import checks, exceptions
from django.db import connection, router
from django.db.backends import utils
from django.db.models import Q
from djan... |
e43ee318b13674af9402d69cf5a57a6b30605831f9959f95ad888ff5f949d379 | 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 OrderBy, Random, RawSQL,... |
08aafe474541baef6a3edb5a040b0d3e8422a65dffc8ce4855235160dd560d85 | from django.db import InterfaceError
from django.db.backends.base.features import BaseDatabaseFeatures
class DatabaseFeatures(BaseDatabaseFeatures):
interprets_empty_strings_as_nulls = True
has_select_for_update = True
has_select_for_update_nowait = True
has_select_for_update_skip_locked = True
ha... |
f3755b974f10409dd5f2399278ee86c180c77110c0347f099af2d3d34d80d85d | """
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... |
a18d5d9a821e2e1aa97068b0c9f30b60f2de0b3cd666d0746eeeab37d1a037ef | import datetime
import uuid
from functools import lru_cache
from django.conf import settings
from django.db import DatabaseError
from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.utils import strip_quotes, truncate_name
from django.db.models import AutoField, Exists, Express... |
d8b4b6e9b5e92f3e3235827585bcb44ef77cd3f68fa3ff64c3ef9bd37b78bb7a | import sys
from django.conf import settings
from django.db import DatabaseError
from django.db.backends.base.creation import BaseDatabaseCreation
from django.utils.crypto import get_random_string
from django.utils.functional import cached_property
TEST_DATABASE_PREFIX = 'test_'
class DatabaseCreation(BaseDatabaseCr... |
df607af77089d9b890bc9658bbe5db439950740231434b0693ab782258be52c7 | from django.db import ProgrammingError
from django.utils.functional import cached_property
class BaseDatabaseFeatures:
gis_enabled = False
allows_group_by_pk = False
allows_group_by_selected_pks = False
empty_fetchmany_value = []
update_can_self_select = True
# Does the backend distinguish be... |
79d432035129bee0aebe054862036dc31b55266c843d00f902186330649fb382 | import copy
import threading
import time
import warnings
from collections import deque
from contextlib import contextmanager
import _thread
import pytz
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import DEFAULT_DB_ALIAS, DatabaseError
from django.db.backends... |
320ddff4d097818ec989651d5139cfe85c163d6a528798529942ca28425b0c8b | 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:
... |
eb5a3995377bc7d070c7ecbabf13bfb936e17e4890e836a681c2df032d775484 | 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... |
37b5a75a8d17dc68a0d9f540bd170bf515acb14200d1ffdb75c8c4655548a058 | """
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... |
cf655a30401fb23611ffe9074158aa4ffb48d77ff666d303abe48aaf1b418e8d | import subprocess
import sys
from django.db.backends.base.creation import BaseDatabaseCreation
from .client import DatabaseClient
class DatabaseCreation(BaseDatabaseCreation):
def sql_table_creation_suffix(self):
suffix = []
test_settings = self.connection.settings_dict['TEST']
if test_... |
ab6c764cdb82d35745f08eac3769d07c7070afe9adf7ed0d2dfa68779d09565e | import operator
from django.db import InterfaceError
from django.db.backends.base.features import BaseDatabaseFeatures
from django.utils.functional import cached_property
class DatabaseFeatures(BaseDatabaseFeatures):
allows_group_by_selected_pks = True
can_return_columns_from_insert = True
can_return_row... |
e61761e02123650cdbc6ab716173f3041dda13826739b2c4743d8d3b39d288e1 | from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo, TableInfo,
)
from django.db.models import Index
class DatabaseIntrospection(BaseDatabaseIntrospection):
# Maps type codes to Django Field types.
data_types_reverse = {
16: 'BooleanField',
17: 'BinaryF... |
dbb5db51f2d4054074cb7634f0c979303a178ecfa90d946ebb9c9569269abd5e | """
PostgreSQL database backend for Django.
Requires psycopg 2: https://www.psycopg.org/
"""
import asyncio
import threading
import warnings
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError as WrappedDatabaseError, connections
from django.db... |
cbad5692a71e70d5cd03b6f78bff1686e1c06a00327b2eacce8f9fae94b3be44 | from psycopg2.extras import Inet
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
class DatabaseOperations(BaseDatabaseOperations):
cast_char_field_without_max_length = 'varchar'
explain_prefix = 'EXPLAIN'
cast_data_types = {
'AutoField': 'int... |
5b9dd79a161cc03b862b7132d7771d7ecf6a12f039cc5dbc6e76de53e09f200c | import sys
from psycopg2 import errorcodes
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.utils import strip_quotes
class DatabaseCreation(BaseDatabaseCreation):
def _quote_name(self, name):
return self.connection.ops.quote_name(name)
def _get_database_cr... |
7720b5b00f06979ef39d82529f5604f6ccc1108564385544c8ef02eb5794631a | 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... |
7b06ab51f29d02cc55c64362dbb5196edfdeaec4e60cb998c6ef0898a3edd09e | """
SQLite backend for the sqlite3 module in the standard library.
"""
import datetime
import decimal
import functools
import hashlib
import math
import operator
import re
import statistics
import warnings
from itertools import chain
from sqlite3 import dbapi2 as Database
import pytz
from django.core.exceptions impor... |
6eefa9a8c40199e7b97e8f2670a16ff6205aa5513b51ef0be23d160162c48194 | 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... |
c25061766665f3efac55e27a70d96129560fa85065508c93860ce03e74697f6b | 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... |
34aea7b435c69081b50bfc2740096d527187781535026fafcc955eed5df9006a | """
Interfaces for serializing Django objects.
Usage::
from django.core import serializers
json = serializers.serialize("json", some_queryset)
objects = list(serializers.deserialize("json", json))
To add your own serializers, use the SERIALIZATION_MODULES setting::
SERIALIZATION_MODULES = {
... |
80c3ba94562aa978991d4d70dd677e9e6e47e9af7f6e0e171bdb1daf41a3a33a | from django.db.models import (
CharField, Expression, Field, FloatField, Func, Lookup, TextField, Value,
)
from django.db.models.expressions import CombinedExpression
from django.db.models.functions import Cast, Coalesce
class SearchVectorExact(Lookup):
lookup_name = 'exact'
def process_rhs(self, qn, con... |
acecec76def0cacb5b5de5cdb2567dd38842d9133e3791af8460c8cd87174abe | from django.contrib.postgres.signals import (
get_citext_oids, get_hstore_oids, register_type_handlers,
)
from django.db import NotSupportedError
from django.db.migrations import AddIndex, RemoveIndex
from django.db.migrations.operations.base import Operation
class CreateExtension(Operation):
reversible = Tru... |
020915fd4792cbd43fb7f586e049ef40bdf815b17917711ea5e67ee98f24d354 | from itertools import chain
from types import MethodType
from django.apps import apps
from django.conf import settings
from django.core import checks
from .management import _get_builtin_permissions
def check_user_model(app_configs=None, **kwargs):
if app_configs is None:
cls = apps.get_model(settings.A... |
2b9c4655499bb362c0828fdac276936567fad987a09470afa3f81708ad94e5b8 | 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... |
b1c57c9220abb022c896e326ab3301735f47a6e87b3b813a9b8ba4e917666310 | """
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... |
933a08b9cfedec3de32d6d0c05c50942fa5c5bb48b859c7fee4ecc99989d09b0 | from django.contrib.postgres.fields import ArrayField, JSONField
from django.db.models import Aggregate, Value
from .mixins import OrderableAggMixin
__all__ = [
'ArrayAgg', 'BitAnd', 'BitOr', 'BoolAnd', 'BoolOr', 'JSONBAgg', 'StringAgg',
]
class ArrayAgg(OrderableAggMixin, Aggregate):
function = 'ARRAY_AGG'... |
19e9c6426551dda0596caf102f5e9f4b59202660623802e4c532bc4621263adf | from datetime import datetime, timedelta
from django import forms
from django.conf import settings
from django.contrib import messages
from django.contrib.admin import FieldListFilter
from django.contrib.admin.exceptions import (
DisallowedModelAdminLookup, DisallowedModelAdminToField,
)
from django.contrib.admin.... |
98eee2ea97af441105d82e2955d4129eab87b5a7ceb0e62ee5775e3dad8ef452 | from django.contrib.gis.db.models.fields import (
ExtentField, GeometryCollectionField, GeometryField, LineStringField,
)
from django.db.models import Aggregate
from django.utils.functional import cached_property
__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
class GeoAggregate(Aggregate):
... |
3e0f5ef28ffd8091733b82d2581c5d24ce7055e2fff4b17c547d126106f5d70c | from decimal import Decimal
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
from django.contrib.gis.db.models.sql import AreaField, DistanceField
from django.contrib.gis.geos import GEOSGeometry
from django.core.exceptions import FieldError
from django.db import NotSupportedError
from d... |
868065c5313a32a5f97b9fdec2e12deb698802a6b9a397a8dac9c3e0b0f12e62 | from unittest import mock
from django.apps.registry import apps as global_apps
from django.db import DatabaseError, connection
from django.db.migrations.exceptions import InvalidMigrationPlan
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.graph import MigrationGraph
from django.d... |
75a122019f71bcaa1b59949cd6069e166951fdd09fa46c9bd0ec696d1abde29b | import datetime
import importlib
import io
import os
import sys
from unittest import mock
from django.apps import apps
from django.core.management import CommandError, call_command
from django.db import (
ConnectionHandler, DatabaseError, connection, connections, models,
)
from django.db.backends.base.schema impor... |
5fc624a135dcd64f97befd58640a19c0e8c3239f5a09a45ae8d42b654f19411c | 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 import CreateModel
from django.db.migrations.operations.fields import FieldOperation
f... |
969def4b56e37cee98f92459371ca3c82ee5c50d57c627368e5ecbb156e62875 | 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... |
ee5d644238a6134079cc4c02c432e05337ef77f6dbf48e202f8162103bfbfd24 | from django.apps.registry import Apps
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models
from django.db.migrations.exceptions import InvalidBasesError
from django.db.migrations.operations import (
AddField, AlterField, DeleteModel, RemoveField,
)
from django.db.migrations.... |
81ec7d9042ee06a4ed22afa67494cb583306ec9bd094feaf347a5e9166778f22 | 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
class MockedPasswordResetTokenGenerator(PasswordResetTokenGenerator):
def __init__(self, now):
... |
0c109feff437a0c05b7b1a121f7b0ddc2660f1f0e27de1111dce7bd921ac2e27 | from django.contrib.auth.checks import (
check_models_permissions, check_user_model,
)
from django.contrib.auth.models import AbstractBaseUser
from django.core import checks
from django.db import models
from django.test import (
SimpleTestCase, override_settings, override_system_checks,
)
from django.test.utils... |
39ae50b7e28c78aef9878671e2ad80dca7d0738abba783a9c6fe5f6ebefe58e9 | 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, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher,
check_password, get_hasher, identify_hasher... |
2d82f0ac3b17829a2c07de5fc7b7de9c505f0c34336ff0aee32ace6a073903c4 | import datetime
import re
from decimal import Decimal
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models import (
Avg, Case, Count, DecimalField, DurationField, Exists, F, FloatField, Func,
IntegerField, Max, Min, OuterRef, Subquery, Sum, Value, When,
)
from dj... |
7f954585af10f5e52f297c9a080d919065fa9527b8f57e166f55a70ef7ff9d37 | import datetime
from django.core import signing
from django.test import SimpleTestCase
from django.test.utils import freeze_time
class TestSigner(SimpleTestCase):
def test_signature(self):
"signature() method should generate a signature"
signer = signing.Signer('predictable-secret')
sign... |
ea81564fd2ab214a5fd73fe7f67414b96dda2d33155831eece4380f6334db59a | from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
... |
e9921be49ed128e871c6aa88c4656db04fb63956a539f2c4a27afe21052c5683 | """
Test PostgreSQL full text search.
These tests use dialogue from the 1975 film Monty Python and the Holy Grail.
All text copyright Python (Monty) Pictures. Thanks to sacred-texts.com for the
transcript.
"""
from django.contrib.postgres.search import (
SearchQuery, SearchRank, SearchVector,
)
from django.db impo... |
1ee2de84509bcb63f63a4d20e611246be8baa5bacc5f483e2405fe9807288d9f | import unittest
from migrations.test_base import OperationTestBase
from django.db import NotSupportedError, connection
from django.db.models import Index
from django.test import modify_settings
try:
from django.contrib.postgres.operations import (
AddIndexConcurrently, RemoveIndexConcurrently,
)
... |
19a77e2068666f494174590df108447ae1d62039113259a7a9e13a4e9c3fa31d | import datetime
from unittest import mock
from django.db import IntegrityError, connection, transaction
from django.db.models import CheckConstraint, F, Func, Q
from django.utils import timezone
from . import PostgreSQLTestCase
from .models import HotelReservation, RangesModel, Room
try:
from django.contrib.post... |
1da69f5056bce57e3b32abf7e9e815733a1d8a4199e7d7e5e447b27b1b403298 | # Unit tests for cache framework
# Uses whatever cache backend is set in the test settings file.
import copy
import io
import os
import pickle
import re
import shutil
import tempfile
import threading
import time
import unittest
from pathlib import Path
from unittest import mock
from django.conf import settings
from dj... |
cb069651676d854ed2d8f70892dd82aeca87458a9d9b61823b1f6ccb4311eced | import hashlib
import unittest
from django.test import SimpleTestCase
from django.utils.crypto import (
InvalidAlgorithm, constant_time_compare, pbkdf2, salted_hmac,
)
class TestUtilsCryptoMisc(SimpleTestCase):
def test_constant_time_compare(self):
# It's hard to test for constant time, just test th... |
888f876101821002fcd85068f83f7779d82b85a54204171ae13a060759b7886a | import threading
from datetime import datetime, timedelta
from unittest import mock
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections, models
from django.db.models.manager import BaseManager
from django.db.models.query impo... |
47fc1a6e128a60171ba5cd67f095f8861de90d2392b6c18fab426f4ded619962 | import datetime
from unittest import skipIf, skipUnless
from django.db import connection
from django.db.models import CASCADE, ForeignKey, Index, Q
from django.test import (
TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
)
from django.test.utils import override_settings
from django.utils impo... |
dd1bc0c22fb89b9506c10d2cffe2364670805e9a871972e18eb7883f4e7a76f0 | import datetime
from copy import deepcopy
from django.core.exceptions import FieldError, MultipleObjectsReturned
from django.db import IntegrityError, models, transaction
from django.test import TestCase
from django.utils.translation import gettext_lazy
from .models import (
Article, Category, Child, ChildNullabl... |
2289fd3c62c370cf14fd46f8f1d35a1c837561ea7c958511171a845bfbfb34c6 | """Tests related to django.db.backends that haven't been organized."""
import datetime
import threading
import unittest
import warnings
from django.core.management.color import no_style
from django.db import (
DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connection, connections,
reset_queries, transaction,... |
d208dbec47164f22ed7994654637f5a0b2c8d6997d141f244b96b443a8dd42d8 | import datetime
import itertools
import unittest
from copy import copy
from unittest import mock
from django.core.management.color import no_style
from django.db import (
DatabaseError, DataError, IntegrityError, OperationalError, connection,
)
from django.db.models import (
CASCADE, PROTECT, AutoField, BigAut... |
18ac1100b225dad1d90b4307a6c92fb45992ccf99fab18d3b720b65d3326129a | from django.db import models
class Classification(models.Model):
code = models.CharField(max_length=10)
class Employee(models.Model):
name = models.CharField(max_length=40, blank=False, null=False)
salary = models.PositiveIntegerField()
department = models.CharField(max_length=40, blank=False, null=... |
0d659c0e776649b28fca9da85f888fe94d9ded142f6f754605ff71a60b79f136 | """
Specifying ordering
Specify default ordering for a model using the ``ordering`` attribute, which
should be a list or tuple of field names. This tells Django how to order
``QuerySet`` results.
If a field name in ``ordering`` starts with a hyphen, that field will be
ordered in descending order. Otherwise, it'll be ... |
54f4109b787200f9d886520b6e8ff6ebaa217df5eacf532f8ec0c6cad5d209ff | from math import ceil
from django.db import connection, models
from django.db.models import ProtectedError, RestrictedError
from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .mo... |
a89bce54c6626c7e41d9499e5cfb1596f7ea1e326728ac38d4b1c11103a43ab4 | from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
class P(models.Model):
pass
class R(models.Model):
is_default = models.BooleanField(default=False)
p = models.ForeignKey(P, m... |
b5c63a4da52d6a649e1256113e3a402cbca748669de89aeea1f72dffc5f4bfec | from unittest import mock
from django.core.checks import Error, Warning as DjangoWarning
from django.db import connection, models
from django.test.testcases import SimpleTestCase
from django.test.utils import isolate_apps, override_settings
@isolate_apps('invalid_models_tests')
class RelativeFieldTests(SimpleTestCas... |
b118acdfe68600152565147f58952211059ac695d43f5198412c21c797104d5a | import unittest
from django.conf import settings
from django.core.checks import Error, Warning
from django.core.checks.model_checks import _check_lazy_references
from django.db import connection, connections, models
from django.db.models.functions import Lower
from django.db.models.signals import post_init
from django... |
d8af45d5e4a1287583a80c788ba9380f5118d42459ce19bf56b39d7e64af5101 | import os
import tempfile
import uuid
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.db.models.fields.files import Imag... |
6988fe9c07410695420fda09a21ed86251f2cd783cd319d8c5d1b3c77f23dada | import datetime
import pickle
import unittest
import uuid
from copy import deepcopy
from unittest import mock
from django.core.exceptions import FieldError
from django.db import DatabaseError, connection
from django.db.models import (
Avg, BooleanField, Case, CharField, Count, DateField, DateTimeField,
Duratio... |
7df1fdf7f7baff1ce6f829d538f25b603f513dcc676a8378cfc6de0374c34018 | import datetime
from operator import attrgetter
from django.core.exceptions import FieldError
from django.db import models
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import isolate_apps
from django.utils import translation
from .models import (
Article, ArticleIde... |
81c87ce1c55855d33153f712bb84e1da8ffee54134a305df975ddd298079aba5 | from django.db import models
from django.utils import timezone
class Article(models.Model):
title = models.CharField(max_length=100)
pub_date = models.DateField()
pub_datetime = models.DateTimeField(default=timezone.now)
categories = models.ManyToManyField("Category", related_name="articles")
de... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.