hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
5a3b88a9068c2ccad468be3fe50a204d4fe8604beb1a0deb9dae704393363b1e | from datetime import date
from . import PostgreSQLTestCase
from .models import (
HStoreModel, IntegerArrayModel, NestedIntegerArrayModel,
NullableIntegerArrayModel, OtherTypesArrayModel, RangesModel,
)
try:
from psycopg2.extras import DateRange, NumericRange
except ImportError:
pass # psycopg2 isn't ... |
bd9f9e7bed1256c8feb7a744ffb017b220576d0645ea0b67aa9da5ee52227c66 | import datetime
from unittest import mock
from django.db import (
IntegrityError, NotSupportedError, connection, transaction,
)
from django.db.models import (
CheckConstraint, Deferrable, F, Func, Q, UniqueConstraint,
)
from django.test import skipUnlessDBFeature
from django.utils import timezone
from . impor... |
42f59aa424c5eb29a03213b19b5f00866baae6c77b98c0cfd6cd9137697c1da4 | import datetime
from xml.dom import minidom
from django.contrib.sites.models import Site
from django.contrib.syndication import views
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
from django.test.utils import requires_tz_support
from django.utils import ti... |
62001be722f206f3a9b723ae12f9af6d991bddce064bc147f02b0e6a9a7b441a | from django.contrib.syndication import views
from django.utils import feedgenerator
from django.utils.timezone import get_fixed_timezone
from .models import Article, Entry
class TestRss2Feed(views.Feed):
title = 'My blog'
description = 'A more thorough description of my blog.'
link = '/blog/'
feed_gu... |
cb955b9c95c6b360c33d5a7fb98ca6a199cf026e4f3832c6f705259f6bf813e0 | import datetime
from decimal import Decimal
from unittest import skipIf
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db import connection
from django.db.models import (
BooleanField, Case, Count, DateTimeField, Exists, ExpressionWrapper, F,
FloatField, Func, IntegerField, Max, N... |
7c89963ccb148db7dc64a2834ab1fc7ba6dacd4fa132acc87f9d748816aec282 | import json
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.test import SimpleTestCase, override_settings
from dj... |
195c6d4f06429000c73436df3fdd7fd2d8823e783105a856b4b7437259dd0453 | import unittest
from django.utils.termcolors import (
DARK_PALETTE, DEFAULT_PALETTE, LIGHT_PALETTE, NOCOLOR_PALETTE, PALETTES,
colorize, parse_color_setting,
)
class TermColorTests(unittest.TestCase):
def test_empty_string(self):
self.assertEqual(parse_color_setting(''), PALETTES[DEFAULT_PALETTE... |
efe5605684382b417ba62d1ab4bc930ce243c04a129a068937dc4baa97d777fc | 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... |
0713d403c92935459c9ff7147339dbd881808cbb94643b7d242fa290f2f038b4 | 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... |
346dd104036becbc0549c10a51c448cfd4c50d73eb581e402e39ec1a912157f5 | """
Various complex queries that have been problematic in the past.
"""
from django.db import models
from django.db.models.functions import Now
class DumbCategory(models.Model):
pass
class ProxyCategory(DumbCategory):
class Meta:
proxy = True
class NamedCategory(DumbCategory):
name = models.Ch... |
8a63655d78efb8e177cf6c057017e39cbf45cbe6c695191e5c0424c5427f9bd6 | import operator
from django.db import DatabaseError, NotSupportedError, connection
from django.db.models import Exists, F, IntegerField, OuterRef, Value
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from .models import Number, ReservedName
@skipUnlessDBFeature('supports_select_union')
class... |
f61532c09cacedb97aa570fd818a564f54c39b918000073531544877f6bef482 | import unittest
from unittest import mock
from django.core.exceptions import ValidationError
class TestValidationError(unittest.TestCase):
def test_messages_concatenates_error_dict_values(self):
message_dict = {}
exception = ValidationError(message_dict)
self.assertEqual(sorted(exception.... |
45b5d3f9fb5442c003931f743cc2617640c7f02336c23830ec796de9d6634d6d | from datetime import datetime
from django.contrib.sitemaps import GenericSitemap
from django.test import override_settings
from .base import SitemapTestsBase
from .models import TestModel
@override_settings(ABSOLUTE_URL_OVERRIDES={})
class GenericViewsSitemapTests(SitemapTestsBase):
def test_generic_sitemap_at... |
3cdf35031d866b50b40cd22e377e7e2256f5e7e97366ca35a39d2cb704f6fc0d | from datetime import date
from django.test import override_settings
from .base import SitemapTestsBase
@override_settings(ROOT_URLCONF='sitemaps_tests.urls.https')
class HTTPSSitemapTests(SitemapTestsBase):
protocol = 'https'
def test_secure_sitemap_index(self):
"A secure sitemap index can be rende... |
b85f5cff7f38c60850d52069584f80e83af63bf65b1ec119b4e170f9b49b7db7 | import os
from datetime import date
from django.contrib.sitemaps import Sitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import modify_settings, override_settings
from django.utils import translation
from django.utils.formats import localize
... |
4b1f3347f21243ba631b73300562ac4b782b5a2c8b4b547f74134f0e006893fc | import sys
from types import ModuleType
from django.conf import (
DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSG, Settings, settings,
)
from django.core.checks.security import base as security_base
from django.test import TestCase, ignore_warnings
from django.utils.deprecation import RemovedInDjango40Warning
class Def... |
50f0310743139a3bc90de8724a0289eacdf609f6dc2b9f313c6460950fff23e6 | import datetime
import os
from decimal import Decimal
from unittest import mock, skipUnless
from django import forms
from django.core.exceptions import (
NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
)
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import connec... |
cf2806140fed2f54bc17a25d1a8cd25e40a0d182f8e8865d09c57376d16411bb | import unittest
from django.core.exceptions import ImproperlyConfigured
from django.db import ProgrammingError
try:
from django.contrib.gis.db.backends.postgis.operations import (
PostGISOperations,
)
HAS_POSTGRES = True
except ImportError:
HAS_POSTGRES = False
if HAS_POSTGRES:
class Fak... |
2d37126ca4e17f64cac0f9ac0d3c4cb2dc923937dc55169969d40257f9717746 | import copy
import unittest
from functools import wraps
from unittest import mock
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS, connection
from django.db.models import Func
def skipUnlessGISLookup(*gis_lookups):
"""
Skip a test unless a database supports all of gis_lookups.
"""... |
5d5dafdc759a6f01ab524a7a8d710ea9b4b1582c569a3d1a5ae536ee4e6fec34 | import operator
import uuid
from unittest import mock, skipIf
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, OperationalE... |
2a2028a7a56b9cada50d563eaf257ff6f22b4c8504704d84952f37cf647962b8 | import os
import shutil
from unittest import skipIf
from django.core.exceptions import ImproperlyConfigured
from django.core.files import File
from django.core.files.images import ImageFile
from django.test import TestCase
from django.test.testcases import SerializeMixin
try:
from .models import Image
except Impr... |
f759a0500b5ee55e5bbbeaa97f4b7bdcf8a14339981329a9bfb195d4193e805d | import collections.abc
import unittest.mock
import warnings
from datetime import datetime
from django.core.paginator import (
EmptyPage, InvalidPage, PageNotAnInteger, Paginator,
UnorderedObjectListWarning,
)
from django.test import SimpleTestCase, TestCase
from .custom import ValidAdjacentNumsPaginator
from ... |
f59e89e64086a4dba24bf03765e5ba5cc17c1371d769c6ccfec7b972fafa1940 | import datetime
from django.contrib import admin
from django.contrib.admin.models import LogEntry
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.templatetags.admin_list import pagination
from django.contrib.admin.tests import AdminSeleniumTestCase
from django.contrib.admin... |
cf0d578a7a6ddc8c410149a551f4715509cbc0512b783aefb486084cee0e4a53 | from unittest import mock
from django.db import connection, migrations
try:
from django.contrib.postgres.operations import (
BloomExtension, BtreeGinExtension, BtreeGistExtension, CITextExtension,
CreateExtension, CryptoExtension, HStoreExtension, TrigramExtension,
UnaccentExtension,
)... |
06c93b1a06c1ab1de903301874982db5a8c452e2058787b90b294e44997c49cf | import re
import types
from unittest import TestCase
from django import forms
from django.core import validators
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
class TestFieldWithValidators(TestCase):
def test_all_errors_get_reported(self):
... |
f2e2aaaee2c9715dc9cd3f18e01fb60eba86aa6979af51a1ec66b21b080ce90d | from datetime import date, datetime
from django.conf.urls.i18n import i18n_patterns
from django.contrib.sitemaps import GenericSitemap, Sitemap, views
from django.http import HttpResponse
from django.urls import path
from django.utils import timezone
from django.views.decorators.cache import cache_page
from ..models ... |
db31ee0e6618856a17c4e6a65b1d0b501be90e73ddbbe9f6184e5b289a2c8706 | import unittest
from io import StringIO
from unittest import mock
from django.core.exceptions import ImproperlyConfigured
from django.db import DatabaseError, connection, connections
from django.db.backends.base.base import BaseDatabaseWrapper
from django.test import TestCase, override_settings
@unittest.skipUnless(... |
b2768ec379c0b9a426189916faffb1d05f4dbe5cbc9aca8e7fdd4ef4fd5cf852 | import unittest
from contextlib import contextmanager
from io import StringIO
from unittest import mock
from django.db import DatabaseError, connection
from django.db.backends.base.creation import BaseDatabaseCreation
from django.test import SimpleTestCase
try:
import psycopg2 # NOQA
except ImportError:
pass... |
c68bb5eba64c67fc2219e6b146df49f921d197c3b30a98b36a88080fef5fcc6d | import os
import re
from django.contrib.gis.db.models import Extent3D, Union
from django.contrib.gis.db.models.functions import (
AsGeoJSON, AsKML, Length, Perimeter, Scale, Translate,
)
from django.contrib.gis.geos import GEOSGeometry, LineString, Point, Polygon
from django.test import TestCase, skipUnlessDBFeatu... |
dcd19c3d6d89f2b159f218ac4907e949aee82a2b46a044c50ceba94458690aad | import json
from django.contrib.gis.db.models.fields import BaseSpatialField
from django.contrib.gis.db.models.functions import Distance
from django.contrib.gis.db.models.lookups import DistanceLookupBase, GISLookup
from django.contrib.gis.gdal import GDALRaster
from django.contrib.gis.geos import GEOSGeometry
from dj... |
478adbd675eebb3ec41f826644b0e1d61691426e14aeb9f48b54bc029d0a369e | 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.module_loading import import_string, module_has_submodule
APPS_MODULE_NAME = 'apps'
MODELS_MODULE_NAME = ... |
1785921fbc0673e5cb85ca9bbb9dde2c382e2a7c10cc5a80bab618644b4962f4 | """
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
####... |
e3c575166f8222f14184a769c84f00e8427f7f1a41770448f980f250de5685b7 | import functools
import re
from itertools import chain
from django.conf import settings
from django.db import models
from django.db.migrations import operations
from django.db.migrations.migration import Migration
from django.db.migrations.operations.models import AlterModelOptions
from django.db.migrations.optimizer ... |
9b99a1d807e322e66c86ab16e31b86591770c5322d581deda5a8ef20bc65f466 | 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... |
0ff9dfc33e3cda07fb9c4310512016aee5bd48451d11516107d7c04a05d60b52 | """Database functions that do comparisons or type conversions."""
from django.db.models.expressions import Func, Value
from django.utils.regex_helper import _lazy_re_compile
class Cast(Func):
"""Coerce an expression to a new field type."""
function = 'CAST'
template = '%(function)s(%(expressions)s AS %(db... |
7b78726b08e91df7e166da2b0ad391108fb49974a79535c6ac2b598b00f5ea0f | from .comparison import Cast, Coalesce, Collate, Greatest, Least, NullIf
from .datetime import (
Extract, ExtractDay, ExtractHour, ExtractIsoWeekDay, ExtractIsoYear,
ExtractMinute, ExtractMonth, ExtractQuarter, ExtractSecond, ExtractWeek,
ExtractWeekDay, ExtractYear, Now, Trunc, TruncDate, TruncDay, TruncHo... |
79cc2c0a0107cafec76d312b7ecebaf8be3349612306d56c7109a7eda98ce8f4 | import collections
import re
from functools import partial
from itertools import chain
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import DatabaseError, NotSupportedError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import F, OrderBy, Random, RawS... |
ea6c4064a51f103b80905b07c49814071e9dd4bd83f60b4b3b5bcc0c4bdb5a36 | from django.db import InterfaceError
from django.db.backends.base.features import BaseDatabaseFeatures
from django.utils.functional import cached_property
class DatabaseFeatures(BaseDatabaseFeatures):
interprets_empty_strings_as_nulls = True
has_select_for_update = True
has_select_for_update_nowait = True... |
446a4449d92152b83935464b9999c14118543f92180d5ea15009a095f766e5c3 | 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... |
b9d013fe6d5dd35484d0b7bc2a4f8a9f61e13f10a63c708b9afbf9f6426c5237 | 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... |
b8fc03f7668ae3802664ae4270ed5f43beb08c3497044fdab770730fa0e0b111 | 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... |
4fcce392fe4f14a9a51052ef6fe433bbc3441382a93cdcc6b20ced199b62dd1a | import operator
import platform
from django.db import transaction
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.utils import OperationalError
from django.utils.functional import cached_property
from .base import Database
class DatabaseFeatures(BaseDatabaseFeatures):
# SQLite c... |
a279356f9ebb8166164f6921bf097d1a5c950bb0701525ea7ada718c0cdb7139 | import base64
import logging
import string
import warnings
from datetime import datetime, timedelta
from django.conf import settings
from django.contrib.sessions.exceptions import SuspiciousSession
from django.core import signing
from django.core.exceptions import SuspiciousOperation
from django.utils import timezone
... |
eff1b315a62df85ce135a280c5fc79946b201b0f4434cf987bb746a0fd94c4c0 | import functools
import re
from unittest import mock
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import AbstractBaseUser
from django.core.validators import RegexValidator, validate_slug
from django.db import connection, migrations, models
from django.db.migrations.auto... |
bce776093cef19c2e08fa9bf853266c032007338e41f1b84d161786f19a1f418 | import threading
import time
from unittest import mock
from multiple_database.routers import TestRouter
from django.core.exceptions import FieldError
from django.db import (
DatabaseError, NotSupportedError, connection, connections, router,
transaction,
)
from django.test import (
TransactionTestCase, ove... |
6f62e6f78131342c1275b5c7c6e9c4eb277be364fd543cbb8eca45ebb5542491 | from django.db import models
class Entity(models.Model):
pass
class Country(Entity):
name = models.CharField(max_length=30)
class EUCountry(Country):
join_date = models.DateField()
class City(models.Model):
name = models.CharField(max_length=30)
country = models.ForeignKey(Country, models.CA... |
a0f33f160a542ae842de492909d31c011654f61e7d3b0b05ef34324123241483 | from django.contrib import admin
from django.contrib.admin.tests import AdminSeleniumTestCase
from django.contrib.auth.models import User
from django.test import TestCase, override_settings
from django.urls import path, reverse
class AdminSiteWithSidebar(admin.AdminSite):
pass
class AdminSiteWithoutSidebar(admi... |
3010fb7d0ec1f9dd80ca7ca27c253cf6a065bb041be884808c89ac03ca827e2f | from django.db.models.signals import post_save, pre_save
from django.test import TestCase
from .models import Account, Employee, Person, Profile, ProxyEmployee
class UpdateOnlyFieldsTests(TestCase):
msg = (
'The following fields do not exist in this model, are m2m fields, or '
'are non-concrete f... |
87ec25062ab104a3bb6da2aaca26642f4a50b73649c7bd23a34a5a464dd34af4 |
from django.db import models
class Account(models.Model):
num = models.IntegerField()
class Person(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
name = models.CharField(max_length=20)
gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
pid =... |
eb005cb0dc60a00ae18ee1d4aaf37d0e4ffc6b462eec0e956c4513fca12204fd | 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... |
f0a4807ffce4b94fbca0966dd4cbd235b43474eceba45afbf06743e9c0cf8700 | import copy
import datetime
from operator import attrgetter
from django.core.exceptions import ValidationError
from django.db import models, router
from django.db.models.sql import InsertQuery
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import isolate_apps
from django.utils.timezone im... |
d49c76efec714afe48cfa86e8da30f79ee6807b6cfc4bf8858d15ca7673d9872 | import base64
import os
import shutil
import string
import tempfile
import unittest
from datetime import timedelta
from http import cookies
from pathlib import Path
from django.conf import settings
from django.contrib.sessions.backends.base import UpdateError
from django.contrib.sessions.backends.cache import SessionS... |
0fa873954a16d84a28a079caf7a89f70bf9db86161b0e7a2cd39b0f2c7ddcb73 | import asyncore
import base64
import mimetypes
import os
import shutil
import smtpd
import sys
import tempfile
import threading
from email import charset, message_from_binary_file, message_from_bytes
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr
from io import St... |
48ff38bfde82806ae5744cc21dbcc1216fbeaacf27995056e72d5baa66b634fe | from django.apps import AppConfig
default_app_config = 'apps.explicit_default_config_without_apps.ExplicitDefaultConfigWithoutApps'
class ExplicitDefaultConfigWithoutApps(AppConfig):
name = 'apps.explicit_default_config_without_apps'
|
f79388b48e96bf1d92d12d17094a7ee1f59cbc29bdea4ecae8f4064fb44dad80 | from django.apps import AppConfig
default_app_config = 'apps.explicit_default_config_empty_apps.ExplicitDefaultConfigEmptyApps'
class ExplicitDefaultConfigEmptyApps(AppConfig):
name = 'apps.explicit_default_config_empty_apps'
|
f2aaacc32f938a95fac290d68dd8bc40324079643cec7b2aa09464b0516acb14 | from django.db import connection
from django.db.models import F, Value
from django.db.models.functions import Collate
from django.test import TestCase
from ..models import Author
class CollateTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.author1 = Author.objects.create(alias='a', name='Jo... |
82071cd1c60b3142bda7419b8f4db323c8121c587dcff711973fbbc33c50997c | #!/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.'
... |
e8007322cd961bb3044517abb550169b074d05030c8c49b8108b3d64756fe73c | import ctypes
import faulthandler
import io
import itertools
import logging
import multiprocessing
import os
import pickle
import sys
import textwrap
import unittest
from importlib import import_module
from io import StringIO
from django.core.management import call_command
from django.db import connections
from django... |
da03467ed7383b368ea6a8bca399b7d00382ba9459397230356a3f75728567fb | import json
import mimetypes
import os
import sys
from copy import copy
from functools import partial
from http import HTTPStatus
from importlib import import_module
from io import BytesIO
from urllib.parse import unquote_to_bytes, urljoin, urlparse, urlsplit
from asgiref.sync import sync_to_async
from django.conf im... |
7d9dc295a2bc2ac01392ceb2217b27d396447e09ead6d01ccceae1fd44636e50 | import asyncio
import difflib
import json
import posixpath
import sys
import threading
import unittest
import warnings
from collections import Counter
from contextlib import contextmanager
from copy import copy, deepcopy
from difflib import get_close_matches
from functools import wraps
from unittest.suite import _Debug... |
c12948fca788f7832e12db9d72ccd684a9bc57080065927f0cb6432554cb8590 | """Compare two HTML documents."""
from html.parser import HTMLParser
from django.utils.regex_helper import _lazy_re_compile
# ASCII whitespace is U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020
# SPACE.
# https://infra.spec.whatwg.org/#ascii-whitespace
ASCII_WHITESPACE = _lazy_re_compile(r'[\t\n\f\r ]+')
de... |
5e0d53a1148936c2792d57bf6f0fe4bc647626505c54e36728eb551435d9038c | import asyncio
import collections
import logging
import os
import re
import sys
import time
import warnings
from contextlib import contextmanager
from functools import wraps
from io import StringIO
from itertools import chain
from types import SimpleNamespace
from unittest import TestCase, skipIf, skipUnless
from xml.d... |
08b67e7cea83c3781d46215c8309cafc5ac94f1846878532cf1defa9aa4e2fca | """
Views and functions for serving static files. These are only to be used
during development, and SHOULD NOT be used in a production setting.
"""
import mimetypes
import posixpath
import re
from pathlib import Path
from django.http import (
FileResponse, Http404, HttpResponse, HttpResponseNotModified,
)
from dja... |
d03d5ddc05ff93ae2094a9e71fe4ab02c024de39ee7fea2e1c709b80cdf2d323 | import functools
import re
import sys
import types
import warnings
from pathlib import Path
from django.conf import settings
from django.http import Http404, HttpResponse, HttpResponseNotFound
from django.template import Context, Engine, TemplateDoesNotExist
from django.template.defaultfilters import pprint
from djang... |
3898399596f2664e31cc98bc9a09e62e52c12c2d50b327bc7c1dd125843e3003 | import asyncio
import inspect
import warnings
from asgiref.sync import sync_to_async
class RemovedInDjango40Warning(DeprecationWarning):
pass
class RemovedInDjango41Warning(PendingDeprecationWarning):
pass
RemovedInNextVersionWarning = RemovedInDjango40Warning
class warn_about_renamed_method:
def _... |
30c29aaae3bb54792e458cb1b74016bb1aeecc366852e1e0534b834c5ce52bd0 | """
Django's standard crypto functions and utilities.
"""
import hashlib
import hmac
import secrets
import warnings
from django.conf import settings
from django.utils.deprecation import RemovedInDjango40Warning
from django.utils.encoding import force_bytes
class InvalidAlgorithm(ValueError):
"""Algorithm is not ... |
3bcca91ed71c5d92a0d53ed75fcbbf1fc8931579ca04a9ca99fe3a38171b7fd9 | from django.utils.itercompat import is_iterable
def make_hashable(value):
"""
Attempt to make value hashable or raise a TypeError if it fails.
The returned value should generate the same hash for equal values.
"""
if isinstance(value, dict):
return tuple([
(key, make_hashable(... |
a729f735747533ce4d85b2ff3d8185d317c6a4e3ce7b42bb6ba18e1f6f64ff26 | import base64
import calendar
import datetime
import re
import unicodedata
import warnings
from binascii import Error as BinasciiError
from email.utils import formatdate
from urllib.parse import (
ParseResult, SplitResult, _coerce_args, _splitnetloc, _splitparams, quote,
quote_plus, scheme_chars, unquote, unquo... |
2689c8a501819efa438c8e416900977cef50f236eb89eb6a50c855a0512591a7 | """
This module contains helper functions for controlling caching. It does so by
managing the "Vary" header of responses. It includes functions to patch the
header of response objects directly and decorators that change functions to do
that header-patching themselves.
For information on the Vary header, see:
http... |
e889eb8037e99438de8e057537236c4d83e710a0f01ca926e8fa90531183b6e1 | from django.http import HttpResponse
from .loader import get_template, select_template
class ContentNotRenderedError(Exception):
pass
class SimpleTemplateResponse(HttpResponse):
rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
def __init__(self, template, context=None, con... |
4227ef1515e3584f1909aa5932911f37227eba350fe570f9cbfd6968313f0df9 | """Default variable filters."""
import random as random_module
import re
import types
from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from operator import itemgetter
from pprint import pformat
from urllib.parse import quote
from django.utils import formats
from django.... |
9642fdd583c0f5336a0c362350ec5f696e0411da7a8e90e8f6c6cacf534bcdc7 | import re
from django.conf import settings
from django.http import HttpResponsePermanentRedirect
from django.utils.deprecation import MiddlewareMixin
class SecurityMiddleware(MiddlewareMixin):
# RemovedInDjango40Warning: when the deprecation ends, replace with:
# def __init__(self, get_response):
def _... |
03cd7438632141757508686662c8ca0980cb24e708d5c0c0fda743df0f619142 | import re
from urllib.parse import urlparse
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.core.mail import mail_managers
from django.http import HttpResponsePermanentRedirect
from django.urls import is_valid_path
from django.utils.deprecation import MiddlewareMixin
fr... |
1aad435480635b95b79f19fe0c0daca5923704c614bac394a7e10cd2afbf972b | from django.utils.cache import patch_vary_headers
from django.utils.deprecation import MiddlewareMixin
from django.utils.regex_helper import _lazy_re_compile
from django.utils.text import compress_sequence, compress_string
re_accepts_gzip = _lazy_re_compile(r'\bgzip\b')
class GZipMiddleware(MiddlewareMixin):
"""... |
eb482220927f5e7bf42ca98edb9414a927cbb4862bf42bc33fa85bb84d0f5570 | from django.conf import settings
from django.conf.urls.i18n import is_language_prefix_patterns_used
from django.http import HttpResponseRedirect
from django.urls import get_script_prefix, is_valid_path
from django.utils import translation
from django.utils.cache import patch_vary_headers
from django.utils.deprecation i... |
e28faa0c06494def07155fd48c708f91189627c6c12709c3bf31c4a76f114284 | """
Clickjacking Protection Middleware.
This module provides a middleware that implements protection against a
malicious site loading resources from your site in a hidden frame.
"""
from django.conf import settings
from django.utils.deprecation import MiddlewareMixin
class XFrameOptionsMiddleware(MiddlewareMixin):
... |
479df286e6dc2a5361712dae8c29ea9977301e6d344a130d033fea2d120e8769 | """
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... |
39c442f28a91a568c01336336c9716c6d7aafb8c46f0554462a5a340f15efaf1 | from urllib.parse import urlsplit, urlunsplit
from asgiref.local import Local
from django.utils.functional import lazy
from django.utils.translation import override
from .exceptions import NoReverseMatch, Resolver404
from .resolvers import _get_cached_resolver, get_ns_resolver, get_resolver
from .utils import get_ca... |
fba8baebbe0843e1162f2ce2d4eb0474f4b2e7a2648e18908755e0433aabdacb | """
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... |
6dd7fc4f285f2e4fee951cfdde210e56d710b3ca003a3fdca12c7fec53fd7ca6 | from django.core.exceptions import ValidationError
from django.forms import Form
from django.forms.fields import BooleanField, IntegerField
from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput, NumberInput
from django.utils.functional import cached_property
from django.utils.html import... |
1d47eca6a6e91cd574aed269b792b18f6cc5aa71bdd5b7c74b4f8b28073533ee | """
HTML Widget classes
"""
import copy
import datetime
import warnings
from collections import defaultdict
from itertools import chain
from django.forms.utils import to_current_timezone
from django.templatetags.static import static
from django.utils import datetime_safe, formats
from django.utils.datastructures impo... |
8ccbcfb2abc74ae595cc253b9fb73e4e36343e03193788f2fe9ada041364168f | """
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... |
da3c4c3bca488c4289fcfbad77f6397efd69125c0c28fecef18eb9b4bc199f10 | import functools
from pathlib import Path
from django.conf import settings
from django.template.backends.django import DjangoTemplates
from django.template.loader import get_template
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
ROOT = Path(__file__).parent
... |
b6ff92063ef74abf9426191922908fd19655a6d5d6ba155ffa08a1e8344c960f | """
Global Django exception and warning classes.
"""
import operator
from django.utils.hashable import make_hashable
class FieldDoesNotExist(Exception):
"""The requested model field does not exist"""
pass
class AppRegistryNotReady(Exception):
"""The django.apps registry is not populated yet"""
pass... |
6ae2750beb9048b718acbd1f015b7b1134c8088592b69bcc8d1bf4b0de03b916 | """
Multi-part parsing for file uploads.
Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
file upload handlers for processing.
"""
import base64
import binascii
import cgi
import collections
import html
import os
from urllib.parse import unquote
from django.conf import settings
from djan... |
fdfb7655afa2d5f1067c2405e0506a278963b6773d681e1ffe37ee577a36b968 | import datetime
import json
import mimetypes
import os
import re
import sys
import time
from collections.abc import Mapping
from email.header import Header
from http.client import responses
from urllib.parse import quote, urlparse
from django.conf import settings
from django.core import signals, signing
from django.co... |
5b3f5b8565933b02272ab23ffb6abb3c548550335bb6653a008493f6b4121442 | import cgi
import codecs
import copy
import warnings
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,... |
978807ee1ed62477ea6f3c3f88ce390c4e4864f4e7ff03eeb1edc86258ba0ec6 | from decimal import Decimal
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.template.base import TokenType, render_value_in_context
from django.template.defaulttags import token_kwargs
from django.utils import translation
from django.utils.safestrin... |
d801388d425255fdf6fc4b4eff275daaf18b6984357496dd5c0fb74d44ca0fdb | from functools import wraps
def no_append_slash(view_func):
"""
Mark a view function as excluded from CommonMiddleware's APPEND_SLASH
redirection.
"""
# view_func.should_append_slash = False would also work, but decorators are
# nicer if they don't have side effects, so return a new function.
... |
48d782e0b843d12eff3427f62ec437993ff9a6112ea7e978b3ab22dd3f3e3b5a | """
Decorators for views based on HTTP headers.
"""
from calendar import timegm
from functools import wraps
from django.http import HttpResponseNotAllowed
from django.middleware.http import ConditionalGetMiddleware
from django.utils.cache import get_conditional_response
from django.utils.decorators import decorator_f... |
237a22f71e7f6643e3b67c1f6c8d16f41de5e66b941b0cb39dadb015c83aabeb | import logging
from functools import update_wrapper
from django.core.exceptions import ImproperlyConfigured
from django.http import (
HttpResponse, HttpResponseGone, HttpResponseNotAllowed,
HttpResponsePermanentRedirect, HttpResponseRedirect,
)
from django.template.response import TemplateResponse
from django.... |
10830d4ffa83dd103259835b0e1ec478ac0337f078b228fa3c2cbae18a6db3e2 | # This file is distributed under the same license as the Django package.
#
# The *_FORMAT strings use the Django date format syntax,
# see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
DATE_FORMAT = 'j. F Y'
TIME_FORMAT = 'H:i'
DATETIME_FORMAT = 'j. F Y H:i'
YEAR_MONTH_FORMAT = 'F Y'
MONTH_DAY_FORM... |
451798f17fa91668fa4dfb180dfb488307f5781f73982f3807a5400e3c0e5b87 | """
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... |
327b326958ee1b96a26e48ad46fba4137fc15b479201c7b1bbaf889419ee7540 | 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... |
573e11a52c8ece95556048b0b4c547057db8e8f07f5bbf8a7745579480478a34 | 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... |
204378ce3a1209788dbb0854ccfdd86b76f6554f54e8ace7609171f7545c11e6 | import functools
from collections import namedtuple
def make_model_tuple(model):
"""
Take a model or a string of the form "app_label.ModelName" and return a
corresponding ("app_label", "modelname") tuple. If a tuple is passed in,
assume it's a valid model tuple already and return it unchanged.
"""... |
bddd6f7014edfc2935c8b20ffae45d67dc4501ad1df5ccdd0e40a0b241e672ef | 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... |
ab4f59f996cb590faeef8f67b3af92b53af7edb3b345622c8809bf2082d8e35f | 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):
... |
be4883bcd25149c1dfbcf3c01fe3f835fc0ef215fcde92b97a90de8ea988670f | import itertools
import math
import warnings
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... |
2f1b758b8e362662e6be1118d0410f68ed94814ee641fad84a9ca70bd5e229e3 | from collections import namedtuple
from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT
def resolve_relation(model, app_label=None, model_name=None):
"""
Turn a model class or model reference string and return a model tuple.
app_label and model_name are used to resolve the scope o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.