hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
e452d3298b4bb88fa6c0c9696fa300b9a57717d34aff3858b81184b1856fdb93 | "Base Cache class."
import time
import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import import_string
class InvalidCacheBackendError(ImproperlyConfigured):
pass
class CacheKeyWarning(RuntimeWarning):
pass
class InvalidCacheKey(ValueError):
pass
... |
655e215bac002f3ec7eb42962a9c7af25cf4b0b05d338b83e674362d18df1d18 | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class SiteMapsConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'django.contrib.sitemaps'
verbose_name = _("Site Maps")
|
1adcd7243ad419a6503c706bf1c8973ed6fbeaeade8d792e1be037e0dbd2c09f | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class RedirectsConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'django.contrib.redirects'
verbose_name = _("Redirects")
|
0e035995ca77935434adec6d8cc344b5a6e2609a2fc582ec7aa6a6c4572fb7f9 | from django.apps import AppConfig
from django.core import checks
from django.db.models.query_utils import DeferredAttribute
from django.db.models.signals import post_migrate
from django.utils.translation import gettext_lazy as _
from . import get_user_model
from .checks import check_models_permissions, check_user_mode... |
10e2b56899ddddaab71d6c023a2aa91396240fc777aad0a44d59bec235b8258d | import unicodedata
from django import forms
from django.contrib.auth import (
authenticate, get_user_model, password_validation,
)
from django.contrib.auth.hashers import (
UNUSABLE_PASSWORD_PREFIX, identify_hasher,
)
from django.contrib.auth.models import User
from django.contrib.auth.tokens import default_to... |
4600209e9489a6ba12d02fb7103e5016e39127d302706c591edd6714f62faf5c | from django.apps import AppConfig
from django.contrib.admin.checks import check_admin_app, check_dependencies
from django.core import checks
from django.utils.translation import gettext_lazy as _
class SimpleAdminConfig(AppConfig):
"""Simple AppConfig which does not do automatic discovery."""
default_auto_fi... |
2b4ef1d293384781f2e86586ec4cad996d92a5638da0d85a7483914cfd7743f7 | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class FlatPagesConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'django.contrib.flatpages'
verbose_name = _("Flat Pages")
|
7dda3872c6f7353e2ab7f02108669899b9112d2645ab3b4a3d71e74a11a48236 | from django.apps import AppConfig
from django.contrib.sites.checks import check_site_id
from django.core import checks
from django.db.models.signals import post_migrate
from django.utils.translation import gettext_lazy as _
from .management import create_default_site
class SitesConfig(AppConfig):
default_auto_fi... |
b9e097b74c39042a3c5183fb715d3a9156fff280fdd20dcf2e9ff8d8cd4d6d23 | from django.apps import AppConfig
from django.contrib.contenttypes.checks import (
check_generic_foreign_keys, check_model_name_lengths,
)
from django.core import checks
from django.db.models.signals import post_migrate, pre_migrate
from django.utils.translation import gettext_lazy as _
from .management import (
... |
6eac1b1fbd1d9e5075301afa5125e2219dc6c5808ab91d5a0247b36f977080a1 | from django.apps import AppConfig
from django.core import serializers
from django.utils.translation import gettext_lazy as _
class GISConfig(AppConfig):
default_auto_field = 'django.db.models.AutoField'
name = 'django.contrib.gis'
verbose_name = _("GIS")
def ready(self):
serializers.BUILTIN_S... |
83c49ae149c65cc45df62fd81f8078579fb122b9697ee50932276cf4618d3b72 | 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... |
5a277ec360094c0b7236031652d7420a658de436e3da311fae02c8e3ded33159 | from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
from django.db.backends.sqlite3.features import (
DatabaseFeatures as SQLiteDatabaseFeatures,
)
from django.utils.functional import cached_property
class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures):
can_alter_geomet... |
0123220eaa24c3e5b4d2bb119cd255ea824314baf59ff55d2a7c0b71b17a89da | """
Tests for django.core.servers.
"""
import errno
import os
import socket
from http.client import HTTPConnection
from urllib.error import HTTPError
from urllib.parse import urlencode
from urllib.request import urlopen
from django.core.servers.basehttp import WSGIServer
from django.test import LiveServerTestCase, ove... |
7439214857ac478e39ac8ae715a1a58cdd5bf7c9faff5eeb5f32818a15a760bf | from io import BytesIO
from django.core.handlers.wsgi import WSGIRequest
from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer
from django.test import SimpleTestCase
from django.test.client import RequestFactory
from django.test.utils import captured_stderr
class Stub:
def __init__(self, **kwar... |
0fec4a8bfde15fcc86a830d1cb30753f49f99f3b3a88bad7558aef13fe838ffd | from django.db import DEFAULT_DB_ALIAS, connections
from django.test import LiveServerTestCase, TestCase
class LiveServerThreadTest(TestCase):
def run_live_server_thread(self, connections_override=None):
thread = LiveServerTestCase._create_server_thread(connections_override)
thread.daemon = True
... |
cfbb0b091b430c07304e9cf532ecfdf72dc2e49f506dea5c637c108b0d6cf9fa | import datetime
import re
from unittest import mock
from django.contrib.auth.forms import (
AdminPasswordChangeForm, AuthenticationForm, PasswordChangeForm,
PasswordResetForm, ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget,
SetPasswordForm, UserChangeForm, UserCreationForm,
)
from django.contrib.aut... |
76e04347b39183e4baa9adf06004e8e078fd2bdb2d991bc921064737f537686d | import gc
import sys
import weakref
from types import TracebackType
from django.dispatch import Signal, receiver
from django.test import SimpleTestCase
from django.test.utils import override_settings
if hasattr(sys, 'pypy_version_info'):
def garbage_collect():
# Collecting weakreferences can take two coll... |
69c85c9f74e29d5179193701bd31cad091ab3bfd2983fd80a32303d40d4e8f32 | 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,
IntegerField, Max, Min, OuterRef, Subquery, Sum, Value, When,
)
from django.d... |
6e0dff64a69d8cc6037b9d64ddc605540e434b92bcf7d7779a0fbe2cdf46f80b | import os
from django.apps import AppConfig, apps
from django.apps.registry import Apps
from django.contrib.admin.models import LogEntry
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from django.db import models
from django.test import SimpleTestCase, ignore_warnings, override_settings
f... |
c40707c8851ec37006086475261d9e059db50e16fa8e61cb9f99710b84ec22df | from django.apps import AppConfig
class MyAdmin(AppConfig):
name = 'django.contrib.admin'
verbose_name = "Admin sweet admin."
class MyAuth(AppConfig):
name = 'django.contrib.auth'
label = 'myauth'
verbose_name = "All your password are belong to us."
class BadConfig(AppConfig):
"""This clas... |
d505b09010539a7323ba50ec29c75b450b34b7db5084be4c28d9f0d2b76a4be6 | 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,
NullBooleanField, OuterRef, Q, Su... |
97ce691d798de246284394c8f3431fb97072459f7ae84f30310dfa2ce6bc17c1 | # 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 sys
import tempfile
import threading
import time
import unittest
import warnings
from pathlib import Path
from unittest import mock, skipIf
from ... |
22ac0a76b92071ff13b8c90b94e542a13f0751c3db32eedd2ee2a0f1bae212ea | from django.test import SimpleTestCase
from django.utils.connection import BaseConnectionHandler
class BaseConnectionHandlerTests(SimpleTestCase):
def test_create_connection(self):
handler = BaseConnectionHandler()
msg = 'Subclasses must implement create_connection().'
with self.assertRais... |
758a4dc7d5831db605d9135c5b4ddf52868d6fa9abfc708783409c6770a408e0 | """
Tests for django test runner
"""
import unittest
from unittest import mock
from admin_scripts.tests import AdminScriptTestCase
from django import db
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.core.management.... |
6ae7ad21d4ea2c0f059e3a1e9ceb6c3bb17b65129eb20c8419553537ce7227df | import unittest
from django.db import NotSupportedError, connection, transaction
from django.db.models import Count
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import CaptureQueriesContext
from .models import Tag
@skipUnlessDBFeature('supports_explaining_query_execu... |
b4316482ae371a2223a6f9e97f4660ae594d69151ca337766b9207b21d061d4a | import datetime
from unittest import 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 import timez... |
db91e9400eae1ac7462c057c2e7aa5ce5a915b9b6e1d41db6a9cd8c7750785e1 | """Tests for django.db.utils."""
import unittest
from django.core.exceptions import ImproperlyConfigured
from django.db import DEFAULT_DB_ALIAS, ProgrammingError, connection
from django.db.utils import ConnectionHandler, load_backend
from django.test import SimpleTestCase, TestCase
from django.utils.connection import ... |
fe6da4e010f18ddff4a9c8fc27449880317de425523a8f58c5db9cf66a2b4822 | 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... |
7711dd17c83196b8dfd4af610c2ec7f69e3e25a8f2c9e1600154150f693543c9 | from unittest import mock
from django.core import checks
from django.core.checks import Error, Warning
from django.db import models
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import (
isolate_apps, modify_settings, override_settings, override_system_checks,
)
cla... |
899c8c96c26fb1c3e3c7c2f05e7296407e9707e8e1b9ef94ea2b3fbda7ed694a | import sys
from io import StringIO
from django.apps import apps
from django.core import checks
from django.core.checks import Error, Warning
from django.core.checks.registry import CheckRegistry
from django.core.management import call_command
from django.core.management.base import CommandError
from django.db import m... |
04924251298aa9bf2db8a0a8bf071e63167db0f94ed74e5c01cad43db5a58a93 | from django.apps import AppConfig
class CheckDefaultPKConfig(AppConfig):
name = 'check_framework'
class CheckPKConfig(AppConfig):
name = 'check_framework'
default_auto_field = 'django.db.models.BigAutoField'
|
3d62f90fbbbb471cba233e3d766468c0f07f2da6756ab4c68aceb9613748fe29 | """
A series of tests to establish that the command-line management tools work as
advertised - especially with regards to the handling of the
DJANGO_SETTINGS_MODULE and default settings.py files.
"""
import os
import re
import shutil
import socket
import subprocess
import sys
import tempfile
import unittest
from io imp... |
1c6a24d9b95f4846527611228ed9081587e4054a63af6ed60e3dda6672fa307e | import datetime
from decimal import Decimal
from unittest import mock
from django.core.exceptions import FieldError
from django.db import NotSupportedError, connection
from django.db.models import (
Avg, BooleanField, Case, F, Func, IntegerField, Max, Min, OuterRef, Q,
RowRange, Subquery, Sum, Value, ValueRang... |
eb2619c20500af60f90edec28db4759eec7f5cf3a09507ccab9c23694a84b8d0 | from django.core import validators
from django.core.exceptions import ValidationError
from django.db import IntegrityError, connection, models
from django.test import SimpleTestCase, TestCase
from .models import (
BigIntegerModel, IntegerModel, PositiveBigIntegerModel,
PositiveIntegerModel, PositiveSmallIntege... |
4a5ee94ef07d648b25639f0afca44a7d984f0bf85413e0b862b0e600f591d1a7 | from django import forms
from django.db import models
from django.test import SimpleTestCase, TestCase
from .models import Post
class TextFieldTests(TestCase):
def test_max_length_passed_to_formfield(self):
"""
TextField passes its max_length attribute to form fields created using
their ... |
8503b54149ca28edb6abdc8b2f391a6abc142df5a2b8c345ef612a853540f436 | import operator
import uuid
from unittest import mock
from django import forms
from django.core import serializers
from django.core.exceptions import ValidationError
from django.core.serializers.json import DjangoJSONEncoder
from django.db import (
DataError, IntegrityError, NotSupportedError, OperationalError, co... |
356fe2b8691f8c762e635ce8eef5efb3327067bd36573f294a6ddcf8a41696fb | from decimal import Decimal
from django.core import validators
from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase
from .models import BigD, Foo
class DecimalFieldTests(TestCase):
def test_to_python(self):
f = models.DecimalField(max_digits=4... |
65b7bde2e10a4f0845b7292c3ed7f568876b6400c48fb909cdf5e4bc6b86018e | from django.core.exceptions import ValidationError
from django.db import models
from django.test import SimpleTestCase, TestCase
from .models import Post
class TestCharField(TestCase):
def test_max_length_passed_to_formfield(self):
"""
CharField passes its max_length attribute to form fields cre... |
1e97885af07a0ef62042802e31f8e0b77e6736f668ba191b358a5f9321554661 | 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 (
... |
d957c870ea9b0e60ec14a049f79b0891005d19f6ae0bff2298044b04411ab1fe | from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import SimpleTestCase, override_settings
from django.test.utils import isolate_apps
@isolate_apps('model_options')
class TestDefaultPK(SimpleTestCase):
@override_settings(DEFAULT_AUTO_FIELD='django.db.models.None... |
e6bd9c7f20eddb726dbe79481cd322e8c4f942947d06bcecb763275241699a59 | from django.apps import AppConfig
class ModelDefaultPKConfig(AppConfig):
name = 'model_options'
class ModelPKConfig(AppConfig):
name = 'model_options'
default_auto_field = 'django.db.models.SmallAutoField'
class ModelPKNonAutoConfig(AppConfig):
name = 'model_options'
default_auto_field = 'djan... |
9bb33a2e5d9db7f0bad8ca6f89344dce74f36d65837c49ee538e050539029998 | from django.db.models import Prefetch, prefetch_related_objects
from django.test import TestCase
from .models import Author, Book, Reader
class PrefetchRelatedObjectsTests(TestCase):
"""
Since prefetch_related_objects() is just the inner part of
prefetch_related(), only do basic tests to ensure its API h... |
c0495277cf8496138eb528d1670dfb0ea749a3485a7172f60bbcbb32ae855187 | from django.contrib import admin
from django.contrib.admin.decorators import register
from django.contrib.admin.sites import site
from django.core.exceptions import ImproperlyConfigured
from django.test import SimpleTestCase
from .models import Location, Person, Place, Traveler
class NameAdmin(admin.ModelAdmin):
... |
df51aa0eb32b4eb101455fc1bd9a8a345d297cec0e71178f5c5b7b4655d5d45a | import copy
import datetime
import os
from unittest import mock
from django.db import DEFAULT_DB_ALIAS, connection, connections
from django.db.backends.base.creation import (
TEST_DATABASE_PREFIX, BaseDatabaseCreation,
)
from django.test import SimpleTestCase, TransactionTestCase
from django.test.utils import over... |
a43692f10aeb09b283c897ee179e757c519c0fe9d93d953b23e4243c7bfeb5c1 | import json
import math
import re
from decimal import Decimal
from django.contrib.gis.db.models import GeometryField, PolygonField, functions
from django.contrib.gis.geos import (
GEOSGeometry, LineString, Point, Polygon, fromstr,
)
from django.contrib.gis.measure import Area
from django.db import NotSupportedErro... |
9cc2b9e82e10a9df3c4ae19e9fb40baf353feb2f0894b57802781bc14aee9227 | import tempfile
from io import StringIO
from django.contrib.gis import gdal
from django.contrib.gis.db.models import Extent, MakeLine, Union, functions
from django.contrib.gis.geos import (
GeometryCollection, GEOSGeometry, LinearRing, LineString, MultiLineString,
MultiPoint, MultiPolygon, Point, Polygon, from... |
f5024bf876845e40da087cf7894796ed3923d63822a0df5603084fad616ca774 | """
Tests for geography support in PostGIS
"""
import os
from unittest import skipUnless
from django.contrib.gis.db import models
from django.contrib.gis.db.models.functions import Area, Distance
from django.contrib.gis.measure import D
from django.db import NotSupportedError, connection
from django.db.models.function... |
6365e65cfb3af118ea94b6ef4d31e16d74aaae88b42fa4e3fe57b94360cecda0 | 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... |
4fd83326bd73947e06b1e3ec140d28ab64ec0eedc9777a03dab2e1e59773f2cb | from datetime import datetime, timedelta
from decimal import Decimal
from unittest import skipUnless
from django.db import connection
from django.db.models.expressions import RawSQL
from django.db.models.functions import Coalesce, Greatest
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from dja... |
6964edae69da39b5aae8d47e0a1a1f4109f08c37398dee3f94838bbe43bb95b5 | from datetime import datetime, timedelta
from decimal import Decimal
from unittest import skipUnless
from django.db import connection
from django.db.models.expressions import RawSQL
from django.db.models.functions import Coalesce, Least
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django... |
a1471760106b7054a10b55e270853d53e1ba0d1c58e8c65bd1a6c7981056e0f2 | 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... |
d4ca43c0b60fe74febbc37dd4443fb37ada07b6c220cc01f3d4fe7e88d6caa1b | from django.db import migrations, models
from django.db.migrations import operations
from django.db.migrations.optimizer import MigrationOptimizer
from django.db.migrations.serializer import serializer_factory
from django.test import SimpleTestCase
from .models import EmptyManager, UnicodeModel
class OptimizerTests(... |
c08961877437e1e67099c2a96976d1334fc3d8fd104b6fa69970bf3881ef1cfe | from django.contrib.admin.models import LogEntry
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import reverse
from .models import City, State
@override_settings(ROOT_URLCONF='admin_views.urls')
class AdminHistoryViewTests(TestCase):
@classmethod... |
8c295a908b2ab6456a08405d24b524be2886f541d43d2a9f8f129f73fd300972 | 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... |
0de5977377195da9d3db2b844256e11bcda685e20611ba2b375210a4a8710622 | """Functions to parse datetime objects."""
# We're using regular expressions rather than time.strptime because:
# - They provide both validation and parsing.
# - They're more flexible for datetimes.
# - The date/datetime/time constructors produce friendlier error messages.
import datetime
from django.utils.regex_hel... |
0e4aa9ff6259e78a5d53ea4d1ba54ce4859d7d6f19814cc78f6f22c3b74f5822 | 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... |
e1169837bbc06cd6cf518f06dc5924d28475cf8d4d9880732505d9fc629a99cf | from importlib import import_module
from pkgutil import walk_packages
from django.apps import apps
from django.conf import settings
from django.template import TemplateDoesNotExist
from django.template.context import make_context
from django.template.engine import Engine
from django.template.library import InvalidTemp... |
9a45ece2d6b4aae95dbf4742bb4dcba2945939d665ee9b6b458778ea8c4cba35 | 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... |
57a45a19338e83a986246986be8768733636821c40d0252a9fb6c4adcc541a27 | from django.db.backends.utils import names_digest, split_identifier
from django.db.models.query_utils import Q
from django.db.models.sql import Query
__all__ = ['Index']
class Index:
suffix = 'idx'
# The max length of the name of the index (restricted to 30 for
# cross-database compatibility with Oracle)... |
0597d15fe39bd5115a9bd200088176411a8bf3300724cbe255eb72b90b84357e | import logging
from datetime import datetime
from django.db.backends.ddl_references import (
Columns, ForeignKeyName, IndexName, Statement, Table,
)
from django.db.backends.utils import names_digest, split_identifier
from django.db.models import Deferrable, Index
from django.db.transaction import TransactionManage... |
f3060ee127c89bc4a4af963b3ba24e01c6954392cac358eaa99718485589f517 | 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_... |
d7a63628651bc72c0ce329737bf6859eddcf13e7dbd9082a5517a5fea7ed099d | 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... |
e73e0e94b8d01b0544f9c2cd1c584b54af17b0bfb967a8b17e6611a14bf017b0 | from django.db.backends.ddl_references import Statement
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
class PostGISSchemaEditor(DatabaseSchemaEditor):
geom_index_type = 'GIST'
geom_index_ops_nd = 'GIST_GEOMETRY_OPS_ND'
rast_index_wrapper = 'ST_ConvexHull(%s)'
sql_alter_column_... |
37a2a1fb4dd511b823831521829b927117e34e3dead446506766db5b12b9529e | 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, OperationalError, connection,
connections, models,
)
from django.db.back... |
6dea728204eb7ca6387131f4f02148b84a8ec916491a0f7ba92a4882152f4f77 | from pathlib import Path
from template_tests.test_response import test_processor_name
from django.template import Context, EngineHandler, RequestContext
from django.template.backends.django import DjangoTemplates
from django.template.library import InvalidTemplateLibrary
from django.test import RequestFactory, overri... |
5d491a5b40aa3ed3c412662fdab6a4515d67a4e65729e78b9c5b8d9511203dee | import os
from django.apps import AppConfig, apps
from django.apps.registry import Apps
from django.contrib.admin.models import LogEntry
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from django.db import models
from django.test import SimpleTestCase, ignore_warnings, override_settings
f... |
98dc1c21c4389162f9e24c6d690c5a60ae164eaa3c5a35dbde90a6d1ece76982 | import unittest
from datetime import date, datetime, time, timedelta
from django.utils.dateparse import (
parse_date, parse_datetime, parse_duration, parse_time,
)
from django.utils.timezone import get_fixed_timezone
class DateParseTests(unittest.TestCase):
def test_parse_date(self):
# Valid inputs
... |
2cd101b106a9246ce4b626a8ae2cce3dcff4e758fd0edccf803cce833c736ec0 | from unittest import mock
from django.test import SimpleTestCase
from django.utils.functional import cached_property, classproperty, lazy
class FunctionalTests(SimpleTestCase):
def test_lazy(self):
t = lazy(lambda: tuple(range(3)), list, tuple)
for a, b in zip(t(), range(3)):
self.ass... |
99fa8b314a64af08f84d2e45618186954b28c5a78463e3c945ccb59e26f45d06 | from datetime import date, timedelta
from django.template.defaultfilters import add
from django.test import SimpleTestCase
from django.utils.translation import gettext_lazy
from ..utils import setup
class AddTests(SimpleTestCase):
"""
Tests for #11687 and #16676
"""
@setup({'add01': '{{ i|add:"5" }... |
b79afaae137b870f357e2c326f6a08e771d0d7eb0af3ec0015ba1f5fc73b87d7 | from django.utils.version import get_version
VERSION = (4, 0, 0, 'alpha', 0)
__version__ = get_version(VERSION)
def setup(set_prefix=True):
"""
Configure the settings (this happens as a side effect of accessing the
first setting), configure logging and populate the app registry.
Set the thread-local... |
36f809f087ae41df443bb853597e93277b88520d80c3183bef1aeb3cf38a7763 | #!/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.'
... |
ac37c53cdd519a48074e221710b8e621f8ed63b7137918f18ff636b76c1ca85b | # 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... |
444a30837fd6fe6b5d2cbfdd2fbb2e9da06a2ee2c44d14aec99632b263fcce31 | import logging
import threading
import weakref
from django.utils.inspect import func_accepts_kwargs
logger = logging.getLogger('django.dispatch')
def _make_id(target):
if hasattr(target, '__func__'):
return (id(target.__self__), id(target.__func__))
return id(target)
NONE_ID = _make_id(None)
# A ... |
751cd18729bd86568fde051ae0c3755d2b083da6a9bc8b01b303a8459c79a9de | 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... |
a979514f17daddf9c9ae77430692a1ff445622e94340f30ee97e2bc237075aaa | """
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... |
0b431190b591f2546741b5958e2156c3795765292f9c027b3ed261979336757f | """
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
####... |
036ddbc1959a2840e6743c1d40c6421defabf6e08fed79415aea4af432165d6f | 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... |
999690a45ce47c1303502c35db477fdc3063d7b6dc60b4f5226d0d12342af393 | 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... |
f9bb3157a767d6c266c21000fdf05e87987cfc83b1a80e58a2e05111755946ef | 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 _... |
7504bdff0cf8a2e6bff940d473d84048df825b7c37a9b544cdec27136913d495 | import codecs
import datetime
import locale
from decimal import Decimal
from urllib.parse import quote
from django.utils.functional import Promise
class DjangoUnicodeDecodeError(UnicodeDecodeError):
def __init__(self, obj, *args):
self.obj = obj
super().__init__(*args)
def __str__(self):
... |
41ed9b83aa6450004cde5168e6bb7ae53af80ea951995f25d3460fb0b048098b | """
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... |
88219ec2e769bbbf364f304225d591ba0aa7089458422d902d0750c1d935734b | 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, unquote, urlencode as original_urlencode, uses_pa... |
3d0ba6f753b5d57c79212c6842329ece624c4f10f89d8f4a03e68865a98cbf42 | """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.... |
97bdd762dfebaf16bccb3e05d91ed9520785cc647ab93c16780e780ea31944e2 | 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... |
cd814faeac414dd9b729428eedf0784ec150cba016536d9cfc7b6d2aa9f5124e | """
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... |
deca92e82d8b83893db918a231c07f2ab9eaf7fca311f137ac930acc07c5d891 | import pkgutil
from importlib import import_module
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
# For backwards compatibility with Django < 3.2
from django.utils.connection import ConnectionDoesNotExist # NOQA: F401
from django.utils.connection import BaseConnectionHandler
... |
effa82b907ab7e9a511d542c726ca41a9fe0dd75d6b52ca80bc0a68bf8fce8ba | """
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... |
35bb0b76ae4cc9e5922ab9c1bba15f544a9ecf881ec363f808092bd186bb7d20 | """
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... |
02251474074e7b6a1b2f296dfbb6e7d4023c57031f9a4a03422b674416a59570 | """
Field classes.
"""
import copy
import datetime
import json
import math
import operator
import os
import re
import uuid
from decimal import Decimal, DecimalException
from io import BytesIO
from urllib.parse import urlsplit, urlunsplit
from django.core import validators
from django.core.exceptions import Validation... |
f4c20bb24107f9308a8c526c8d7de97205ee31bd5b38ac45c09b263b92de4d42 | """
Functions for creating and restoring url-safe signed JSON objects.
The format used looks like this:
>>> signing.dumps("hello")
'ImhlbGxvIg:1QaUZC:YIye-ze3TTx7gtSv422nZA4sgmk'
There are two components here, separated by a ':'. The first component is a
URLsafe base64 encoded JSON of the object passed to dumps(). T... |
587b09d76b40844571b05b3154ff5f2946e32e9250e4450ddc6e2aabf0cb4dc6 | import ipaddress
import re
import warnings
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit
from django.core.exceptions import ValidationError
from django.utils.deconstruct import deconstructible
from django.utils.deprecation import RemovedInDjango41Warning
from django.utils.encoding import punyc... |
3a2a832c459dbde8a8ee6ab9f7b24aac0639bd7ea387fe0c6864e9357c56e750 | 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... |
e4d3adea10c879eefeb1688c6cd45371effda3fd8423ccbe4a8a37862443f80e | from django.urls import include
from django.views import defaults
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include']
handler400 = defaults.bad_request
handler403 = defaults.permission_denied
handler404 = defaults.page_not_found
handler500 = defaults.server_error
|
7ade6bb7a7c6084c6e1b000a3b4cab99d28ea2ce8276baeb012e7d727876f2c5 | """
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... |
ecdd21b1d5391c40715adf00dcdc81950f69955bc8989ec640ad98232de851f3 | 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... |
6df9169e77857f681d06f99378387cefa8e6ec861247cbdc100015d941b3eaa9 | 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... |
2b4066ab4a6028aa6dd7c7f6b5bbc4cd16f67ee5ab066250e289563c93b97fd6 | """
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... |
5fa9569a03e35e7be387e69f44fcb1bcfa2a4d938a8dd01e641e415ec15f4608 | 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... |
209f3ccb0c823db7a93266512dd9c8674e44f1aa26c7b4660365c8bca3e2ed80 | import copy
import inspect
from importlib import import_module
from django.db import router
from django.db.models.query import QuerySet
class BaseManager:
# To retain order, track each time a Manager instance is created.
creation_counter = 0
# Set to True for the 'objects' managers that are automaticall... |
3f1e23f11c37f58db0085a45cf2f1b734b900ded03ca67be072c5ca276398cc6 | """
Various data structures used in query construction.
Factored out from django.db.models.query to avoid making the main module very
large and/or so that they can be used by other modules without getting into
circular import difficulties.
"""
import copy
import functools
import inspect
from collections import namedtu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.