hash
stringlengths
64
64
content
stringlengths
0
1.51M
8d0e8bad1bd7bbd0a98aa018744259bec178f1ff4328cd476a0bc644f3062072
import base64 import binascii import functools import hashlib import importlib import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.signals import setting_changed from django.dispatch import receiver from django.utils.crypto import ( constant_tim...
04592cef43b463cb3aa757ebf12083e3eca4da48ee72fec7c1371d454cd50c53
from django.dispatch import Signal user_logged_in = Signal() user_login_failed = Signal() user_logged_out = Signal()
0bb2fac95634d1a1204faaeadb94562debd491394fd47dae5f748bf9060959aa
""" This module allows importing AbstractBaseUser even when django.contrib.auth is not in INSTALLED_APPS. """ import unicodedata from django.contrib.auth import password_validation from django.contrib.auth.hashers import ( check_password, is_password_usable, make_password, ) from django.db import models from djang...
f57016a3401907be3e9178ed9b09583948630e2cbe17a0f11e40d2e775b87e77
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...
cba7f349396a564cf560755102b7581b6b7bb5259b9cc395d0cbe3097eb597c7
import json from django import forms from django.conf import settings from django.contrib.admin.utils import ( display_for_field, flatten_fieldsets, help_text_for_field, label_for_field, lookup_field, ) from django.core.exceptions import ObjectDoesNotExist from django.db.models import ManyToManyRel from django...
3544986e515d122b7e42fa1ddb44823371254493d204a71281a07b7125afef9a
import collections from itertools import chain from django.apps import apps from django.conf import settings from django.contrib.admin.utils import ( NotRelationField, flatten, get_fields_from_path, ) from django.core import checks from django.core.exceptions import FieldDoesNotExist from django.db import models f...
7a38fba63e1347a0058b780d5f73cf0d728d6997171e605c448bcafc7cb7ae78
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...
aa52db0abcb50b7bad488b94c6bf2cd433b556257bc2353a12aa9e22b6f4cc62
""" 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...
c499caa453734c978a89dc30b53f146beca58e7dce308a08c8826705fa16e0fb
import datetime import decimal from collections import defaultdict from django.core.exceptions import FieldDoesNotExist from django.db import models, router from django.db.models.constants import LOOKUP_SEP from django.db.models.deletion import Collector from django.forms.utils import pretty_name from django.urls impo...
b89b61f52d245f4ca28c283abaf6dc5787e29796c0a09b199a82969af837d6d0
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ class AdminAuthenticationForm(AuthenticationForm): """ A custom authentication form used in the admin app. """ error_me...
4bec761bb817a7aee48c9f1c28b0a58d711366ddb452ab117618cfc894db2dc8
import fnmatch import os from django.conf import settings from django.core.exceptions import ImproperlyConfigured def matches_patterns(path, patterns): """ Return True or False depending on whether the ``path`` should be ignored (if it matches any pattern in ``ignore_patterns``). """ return any(f...
160951ca83fb52e25d3921ee4ee77c0ae933c27f0b71be3f5e60895150224ec0
import hashlib import json import os import posixpath import re from urllib.parse import unquote, urldefrag, urlsplit, urlunsplit from django.conf import settings from django.contrib.staticfiles.utils import check_settings, matches_patterns from django.core.exceptions import ImproperlyConfigured from django.core.files...
fc27968168e1b83ff2f0580c2a9bfd92f82894dcf5a27dc31f4364bc99f094e3
from django.contrib.sites.models import Site from django.db import models from django.urls import NoReverseMatch, get_script_prefix, reverse from django.utils.encoding import iri_to_uri from django.utils.translation import gettext_lazy as _ class FlatPage(models.Model): url = models.CharField(_('URL'), max_length...
5ceab0dfb87f22d778094e2a0e4d0ad37425ef2ea8324afeb02e8e8f9d981d98
from django import forms from django.conf import settings from django.contrib.flatpages.models import FlatPage from django.core.exceptions import ValidationError from django.utils.translation import gettext, gettext_lazy as _ class FlatpageForm(forms.ModelForm): url = forms.RegexField( label=_("URL"), ...
9242cc81a4067ea04a115f9ded22a553c1e293a76fbb4b860404400c59b294dd
from collections import defaultdict from django.apps import apps from django.db import models from django.utils.translation import gettext_lazy as _ class ContentTypeManager(models.Manager): use_in_migrations = True def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Cac...
3c4102195a075fab227d5dfd1bf8316e041ce7510c47cba96286683a5c2315c2
import functools import itertools import operator from collections import defaultdict from django.contrib.contenttypes.models import ContentType from django.core import checks from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist from django.db import DEFAULT_DB_ALIAS, models, router, transaction fr...
7697eae4e6ed7e6e82e4b66fb10bbfa06e51a32db27000cf6198edbdb76618c8
import time from importlib import import_module from django.conf import settings from django.contrib.sessions.backends.base import UpdateError from django.core.exceptions import SuspiciousOperation from django.utils.cache import patch_vary_headers from django.utils.deprecation import MiddlewareMixin from django.utils....
eb0eb804ab24801f18c3f669895509bed8f378de841a29b37819b166402cff83
import json from django.conf import settings from django.contrib.messages.storage.base import BaseStorage, Message from django.core import signing from django.http import SimpleCookie from django.utils.crypto import constant_time_compare, salted_hmac from django.utils.safestring import SafeData, mark_safe class Mess...
4329c77d5c1095823c2c4c9ac7e80b3901aef5b38ba06e046c175cbf28475c2c
import datetime import json from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange, Range from django.contrib.postgres import forms, lookups from django.db import models from django.db.models.lookups import PostgresOperatorLookup from .utils import AttributeSetter __all__ = [ 'RangeField', 'Intege...
ece1a1fac3f8aad42401958b65fff617450100e5402bc5b9a145b625cc62ba45
import warnings from django.db.models import JSONField as BuiltinJSONField from django.db.models.fields.json import ( KeyTextTransform as BuiltinKeyTextTransform, KeyTransform as BuiltinKeyTransform, ) from django.utils.deprecation import RemovedInDjango40Warning __all__ = ['JSONField'] class JSONField(Buil...
5a60f1bb18542d460ef3f9ca5d7b0ecf6ead6b8a327b4310c07843096e4e7b98
import warnings from django.forms import JSONField as BuiltinJSONField from django.utils.deprecation import RemovedInDjango40Warning __all__ = ['JSONField'] class JSONField(BuiltinJSONField): def __init__(self, *args, **kwargs): warnings.warn( 'django.contrib.postgres.forms.JSONField is depr...
0f7b92c463664b61ee456177efa909c39364d94038b10cf4119078c8378cb43d
from django.contrib.postgres.fields import ArrayField from django.db.models import Aggregate, JSONField, Value from .mixins import OrderableAggMixin __all__ = [ 'ArrayAgg', 'BitAnd', 'BitOr', 'BoolAnd', 'BoolOr', 'JSONBAgg', 'StringAgg', ] class ArrayAgg(OrderableAggMixin, Aggregate): function = 'ARRAY_AGG'...
4a79f6253ca2ae2d26f64eb865697ba6bd0bb4de43f0df288b6148bb6aa8274a
from django.db.models import Aggregate, FloatField, IntegerField __all__ = [ 'CovarPop', 'Corr', 'RegrAvgX', 'RegrAvgY', 'RegrCount', 'RegrIntercept', 'RegrR2', 'RegrSlope', 'RegrSXX', 'RegrSXY', 'RegrSYY', 'StatAggregate', ] class StatAggregate(Aggregate): output_field = FloatField() def __init__(s...
c4fe2e95fe56c3ff2b7f216183785e59ca7ed8966c8c88b885fae0a8973d7ffc
from django.db.models import F, OrderBy class OrderableAggMixin: def __init__(self, *expressions, ordering=(), **extra): if not isinstance(ordering, (list, tuple)): ordering = [ordering] ordering = ordering or [] # Transform minus sign prefixed strings into an OrderBy() expres...
6ff5ddd50b1a0b919ce24b89f9f439cca761795923e1877a02c9a7a3c88d90a3
from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('auth', '0011_update_proxy_permissions'), ] operations = [ migrations.AlterField( model_name='user', name='first_name', field=models.CharField(blank=True,...
b9273530088b6ab256cbf4aea05018ae0501a1a4c02d427742af52beabf9b59d
import sys from django.core.management.color import color_style from django.db import IntegrityError, migrations, transaction from django.db.models import Q WARNING = """ A problem arose migrating proxy model permissions for {old} to {new}. Permission(s) for {new} already existed. Codenames Q: {query...
6b6faa9ddeae90bd35d0e6092b4dde1c92c3d155145c9b0d7175899511eb2a2e
import getpass from django.contrib.auth import get_user_model from django.contrib.auth.password_validation import validate_password from django.core.exceptions import ValidationError from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS UserModel = get_user_model() ...
848557f287ed88b975829b4bef62b855cbd031eccea761b67b708a8e2f1e24fa
#!/usr/bin/env python import argparse import subprocess import sys from pathlib import Path js_path = Path(__file__).parents[1] / 'static' / 'admin' / 'js' def main(): description = """With no file paths given this script will automatically compress files of the admin app. Requires the Google Closure Compiler li...
69dc93034b29e5b7283edffee73e2e0a9d1e53c04523951b72dbd7834fd3ba01
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....
98272bc0159b82eb51deda5a76e44a346dd2853bb9625d138db6b93b9469e615
from inspect import getfullargspec from django.template.library import InclusionNode, parse_bits class InclusionAdminNode(InclusionNode): """ Template tag that allows its template to be overridden per model, per app, or globally. """ def __init__(self, parser, token, func, template_name, takes_c...
37296c07f9f2a4d5da055f797ba15c37b18778e991a00c1aeeb7994904982df8
import datetime from django.contrib.admin.templatetags.admin_urls import add_preserved_filters from django.contrib.admin.utils import ( display_for_field, display_for_value, get_fields_from_path, label_for_field, lookup_field, ) from django.contrib.admin.views.main import ( ALL_VAR, ORDER_VAR, PAGE_VAR, SE...
98e50dc1dbdccc43f688fb3ef0e914b3c375bd9303bd2a4a967310f12b4e1599
import re from datetime import date, datetime from decimal import Decimal from django import template from django.conf import settings from django.template import defaultfilters from django.utils.formats import number_format from django.utils.safestring import mark_safe from django.utils.timezone import is_aware, utc ...
b0fd42d92290b3e473426837113a524f610976c25d09c5ab2f5a2e4c586be0a1
import os from django.apps import apps from django.contrib.staticfiles.finders import get_finders from django.contrib.staticfiles.storage import staticfiles_storage from django.core.files.storage import FileSystemStorage from django.core.management.base import BaseCommand, CommandError from django.core.management.colo...
4d7c792efb01b4cfbbe7477f226238ce91caad79ac7d55574a03b1c1e716d756
from django.apps import apps as global_apps from django.db import ( DEFAULT_DB_ALIAS, IntegrityError, migrations, router, transaction, ) class RenameContentType(migrations.RunPython): def __init__(self, app_label, old_model, new_model): self.app_label = app_label self.old_model = old_model ...
d700c4e5c4b6a883dcf2aaba41eca1c4a00f2d75852c8a9a8c29c9bb368b8666
import itertools from django.apps import apps from django.contrib.contenttypes.models import ContentType from django.core.management import BaseCommand from django.db import DEFAULT_DB_ALIAS, router from django.db.models.deletion import Collector class Command(BaseCommand): def add_arguments(self, parser): ...
f70634125363a54e2193f1d80767b2a4a1c488833d3f5933676754868692cf6c
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 ...
894d66f877dee3ac7013685cbddb03b5ad45ef54dbe7e05038f8e7e87df7cdeb
from importlib import import_module from django.conf import settings from django.core.management.base import BaseCommand class Command(BaseCommand): help = ( "Can be run as a cronjob or directly to clean out expired sessions " "(only with the database backend at the moment)." ) def handl...
ca0faca1404414345299fee220fcdd385122de5bdc40d2a9fc98ac93e730891e
from django.apps import apps from django.contrib.gis.db.models import GeometryField from django.contrib.sitemaps import Sitemap from django.db import models from django.urls import reverse class KMLSitemap(Sitemap): """ A minimal hook to produce KML sitemaps. """ geo_format = 'kml' def __init__(s...
bc9b783b26b820be811c4ef1f19fc59109f50e8e9c69544bf1de611365ca542a
from django.apps import apps from django.contrib.gis.db.models import GeometryField from django.contrib.gis.db.models.functions import AsKML, Transform from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz from django.core.exceptions import FieldDoesNotExist from django.db import DEFAULT_DB_ALIAS, conne...
25b1497bbf332481f9d7f2a4bbd17ca67a58c8994e7207f0e0b6acd75d9e548b
from django import forms from django.contrib.gis.gdal import GDALException from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ from .widgets import OpenLayersWidget class GeometryField(forms.Field): ...
fa0834e2d46d6029343c4f7ac903117abb4535dea0e88c6b3db2c91ffe6f4c9e
import logging import os from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int from ctypes.util import find_library from django.contrib.gis.gdal.error import GDALException from django.core.exceptions import ImproperlyConfigured from django.utils.regex_helper import _lazy_re_compile logger = logging.getLogger('django.co...
76692d9ae9257e75624f79b7a90130b2c1333a40aac8d0f28396a3b94c3d1c23
""" This module houses the ctypes initialization procedures, as well as the notice and error handler function callbacks (get called when an error occurs in GEOS). This module also houses GEOS Pointer utilities, including get_pointer_arr(), and GEOM_PTR. """ import logging import os from ctypes import CDLL, CFUNCT...
9999e3989437214b7047ca0a66c45e4c9e67a998cb06fd1c26aaa802505f4afc
from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin from django.contrib.gis.geos.point import Point from django.contrib.gis....
90911da0ce8bfd35b94996008138af32765b151466d688dfff6c9cc6317b2acd
""" This module houses the GEOSCoordSeq object, which is used internally by GEOSGeometry to house the actual coordinates of the Point, LineString, and LinearRing geometries. """ from ctypes import byref, c_byte, c_double, c_uint from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.bas...
7464d158c3e128ef785cd7fc53c543a22c2e6163ad6b140461786e98209d1ea3
from django.contrib.gis.db.models.fields import ( ExtentField, GeometryCollectionField, GeometryField, LineStringField, ) from django.db.models import Aggregate, Value from django.utils.functional import cached_property __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] class GeoAggregate(Aggregate...
dcca4995b9d81ed2dfc419d26d9f547537d0b11c5e777c5d561e38c9a4da1835
from collections import defaultdict, namedtuple from django.contrib.gis import forms, gdal from django.contrib.gis.db.models.proxy import SpatialProxy from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.geos import ( GeometryCollection, GEOSException, GEOSGeometry, LineString, Multi...
164218b2375125b3a8c1d1fec717fb25fc8fe24070e0aa4fddc16a33afd770d5
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...
df3bc03854b4ab2defaf96465a4e55abcb28e723cf82b2f04c9a091c20f35df5
from django.contrib.gis.db.models.fields import BaseSpatialField from django.contrib.gis.measure import Distance from django.db import NotSupportedError from django.db.models import Expression, Lookup, Transform from django.db.models.sql.query import Query from django.utils.regex_helper import _lazy_re_compile class ...
f6d57cb39dc8dddd5e7009e61a3cb1c0256bc92f74d560b437f09dd326c0a889
import cx_Oracle from django.db.backends.oracle.introspection import DatabaseIntrospection class OracleIntrospection(DatabaseIntrospection): # Associating any OBJECTVAR instances with GeometryField. This won't work # right on Oracle objects that aren't MDSYS.SDO_GEOMETRY, but it is the # only object type...
84b9666a6cb4c8e79b805b26a99666ff8ba2638e3989dfb3c7e7f4778c9e4497
""" This module contains the spatial lookup types, and the `get_geo_where_clause` routine for Oracle Spatial. Please note that WKT support is broken on the XE version, and thus this backend will not work on such platforms. Specifically, XE lacks support for an internal JVM, and Java libraries are required to use...
109393006e2b3eb9ce3005a6c1e727570152c2624e8d94b947fa78f0dc9b0e2d
from django.contrib.gis.db.models import GeometryField from django.db.backends.oracle.schema import DatabaseSchemaEditor from django.db.backends.utils import strip_quotes, truncate_name class OracleGISSchemaEditor(DatabaseSchemaEditor): sql_add_geometry_metadata = (""" INSERT INTO USER_SDO_GEOM_METADATA ...
6b8c7e25929cc7cecf3b376b9e2449cfd47e24e8d50afadf3f1d396573d25aad
import re from django.contrib.gis.db import models class BaseSpatialFeatures: gis_enabled = True # Does the database contain a SpatialRefSys model to store SRID information? has_spatialrefsys_table = True # Does the backend support the django.contrib.gis.utils.add_srs_entry() utility? supports_...
cfa322bab22bb169289185d8b5c029bb58e2e7c6466d0cf54152f10eb2d64ae2
from django.contrib.gis.db.models import GeometryField from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.measure import ( Area as AreaMeasure, Distance as DistanceMeasure, ) from django.db import NotSupportedError from django.utils.functional import cached_property class BaseSpat...
44a14bca3069b8d436973ceb712046d12c5a6118422ee4812f0574545ba83be9
from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.adapter import WKTAdapter from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.geos.geometry import GEOSGeometry...
07ce93785e61be598bce063b4c56464ca688cd56caf3b0723e68e1373f372530
import logging from django.contrib.gis.db.models import GeometryField from django.db import OperationalError from django.db.backends.mysql.schema import DatabaseSchemaEditor logger = logging.getLogger('django.contrib.gis') class MySQLGISSchemaEditor(DatabaseSchemaEditor): sql_add_spatial_index = 'CREATE SPATIAL...
389119518e0d37a8458f486d14370282d190312f1c1086d76928f1a37cb1af49
""" SQL functions reference lists: https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.3.0.html """ from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter from djang...
ddfadd720a602bb87dd8b0ca17f931c762d82114cfc7210ef5e1378191125870
from django.db import DatabaseError from django.db.backends.sqlite3.schema import DatabaseSchemaEditor class SpatialiteSchemaEditor(DatabaseSchemaEditor): sql_add_geometry_column = ( "SELECT AddGeometryColumn(%(table)s, %(column)s, %(srid)s, " "%(geom_type)s, %(dim)s, %(null)s)" ) sql_add_...
9d54b5a5231014a7df29c24d36f1cc5835fc1f1718448586e11bcaf5f8b06c7f
import struct from django.core.exceptions import ValidationError from .const import ( BANDTYPE_FLAG_HASNODATA, BANDTYPE_PIXTYPE_MASK, GDAL_TO_POSTGIS, GDAL_TO_STRUCT, POSTGIS_HEADER_STRUCTURE, POSTGIS_TO_GDAL, STRUCT_SIZE, ) def pack(structure, data): """ Pack data into hex string with little endian...
08c7bf6e9cdc39c61a902de6bbae0429f1761e0471053e32868457eb38373bf9
""" PostGIS to GDAL conversion constant definitions """ # Lookup to convert pixel type values from GDAL to PostGIS GDAL_TO_POSTGIS = [None, 4, 6, 5, 8, 7, 10, 11, None, None, None, None] # Lookup to convert pixel type values from PostGIS to GDAL POSTGIS_TO_GDAL = [1, 1, 1, 3, 1, 3, 2, 5, 4, None, 6, 7, None, None] # ...
e0451d515a124e7737767be543a02fe6c00bb99dd6a04f5f80ad1c2836d3d849
import re from django.conf import settings from django.contrib.gis.db.backends.base.operations import ( BaseSpatialOperations, ) from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import GeometryField, RasterField from django.contrib.gis.gdal import GDALRaster from d...
83a8c2c38da9bac6a151cf380f0e764239d0a6248f4cf6099618f11a77d1107b
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_...
b3492fcc64bcdfaa2ae36e1d422b1967b71cda580e3dfd650a53013b52afcad5
import argparse from django.contrib.gis import gdal from django.core.management.base import BaseCommand, CommandError from django.utils.inspect import get_func_args class LayerOptionAction(argparse.Action): """ Custom argparse action for the `ogrinspect` `layer_key` keyword option which may be an integer...
7189eabb76925e7706001ec76803c595945093ef6c71354e258b21a679999a12
import json import os import sys import uuid from ctypes import ( addressof, byref, c_buffer, c_char_p, c_double, c_int, c_void_p, string_at, ) from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import raster as capi fro...
cca075afffba7da2f2abc38be2a25d33e95b30ca70f0d298625f0bf6d09eb014
from ctypes import POINTER, c_char_p, c_int, c_ubyte from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, GEOSFuncFactory from django.contrib.gis.geos.prototypes.errcheck import ( check_geom, check_minus_one, check_string, ) # This is the return type used by binary output (WKB, HEX) routines. c_uchar_p =...
bf61e8ae4a0e3f560d824372558e80e41df35b11bd55e2090e1e09c7b4ee45ce
class DefaultOtherRouter: def allow_migrate(self, db, app_label, model_name=None, **hints): return db in {'default', 'other'} class TestRouter: def allow_migrate(self, db, app_label, model_name=None, **hints): """ The Tribble model should be the only one to appear in the 'other' db. ...
f54300813a0deba548cac9e33bb6124bdbc020ac46bc8af80f29c7154830eba8
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(...
3551df66799b18d5e61c6dcc81a822f43e571ad72496b3c6c19b1cceaba34bfa
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...
60e649cf7aac4a4a98d6cc6035156f8de18b0517e9c90a0281e2319a995c8cda
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...
b918ef66cdcf40e5bad4f8f81f61d32dee5eb6958c47ba208a151384c2564b18
import compileall import os from django.db import connection, connections from django.db.migrations.exceptions import ( AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, ) from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder from django....
2caa5e49fb9bcac5f99a0f1d948b52272e940d053c665368bb6700d0c915b90d
from django.core.exceptions import FieldDoesNotExist from django.db import ( IntegrityError, connection, migrations, models, transaction, ) from django.db.migrations.migration import Migration from django.db.migrations.operations.fields import FieldOperation from django.db.migrations.state import ModelState, Projec...
45e11d149b6203adf3e22bb6202641819c385f375a6ecbd8369e6f0ece150a8b
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...
d282e2711354614a9c49b1aef7acc2a302724d6b75d81783da178ebd96caf534
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, models from django.db.migrations.autodetector imp...
13815ab5db0032e43038d736baffed5a8b8bfd21c1ca24f6f935c62e571760c6
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....
1ff7fedb3e61a383555eec7070ecc878a3cea30b858e3d338e6c72f7f0acc89d
import re from django.forms import CharField, Form, Media from django.http import HttpRequest, HttpResponse from django.middleware.csrf import ( CsrfViewMiddleware, _compare_masked_tokens as equivalent_tokens, get_token, ) from django.template import TemplateDoesNotExist, TemplateSyntaxError from django.template.b...
ac05dc0cb40b1a27948727a0f2f93339c51ec9a629a818b8f0c403d717e73f53
import os import sys import tempfile import unittest import warnings from io import StringIO from unittest import mock from django.apps import apps from django.contrib.sites.models import Site from django.core import management from django.core.files.temp import NamedTemporaryFile from django.core.management import Co...
58dbda57d127fceeac74dbdc1358de00a11c2ad34be22c6d74e9a5a387d47ac7
""" Fixtures. Fixtures are a way of loading data into the database in bulk. Fixure data can be stored in any serializable format (including JSON and XML). Fixtures are identified by name, and are stored in either a directory named 'fixtures' in the application directory, or in one of the directories named in the ``FIX...
5c005015b3cb11ba131453a3a77afb7e35d93eecb85d49634e7069b27de4aa54
from datetime import datetime from django.core.exceptions import ValidationError from django.db import models def validate_answer_to_universe(value): if value != 42: raise ValidationError('This is not the answer to life, universe and everything!', code='not42') class ModelToValidate(models.Model): ...
4e38ecf96695b19148e3b21ba432b9b56bb446e44a5726f7cb13a3365a597ff0
from unittest import mock from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import path, reverse class Router: target_db = None def db_for_read(self, model, **hints...
b73d7a1aab36f822546bf81d59531459e3ce177b430e40501877f1944e459874
import datetime import itertools import os import re from importlib import import_module from unittest import mock from urllib.parse import quote from django.apps import apps from django.conf import settings from django.contrib.admin.models import LogEntry from django.contrib.auth import ( BACKEND_SESSION_KEY, HAS...
5ec5299163add657f94f4523779e381aa28eb9816acb321a1be0e0a45519b572
from datetime import datetime from django.conf import settings from django.contrib.auth import authenticate from django.contrib.auth.backends import RemoteUserBackend from django.contrib.auth.middleware import RemoteUserMiddleware from django.contrib.auth.models import User from django.middleware.csrf import _get_new_...
13facf4de7abed71f40187756705ff248b7d4c2f9836ca0bf6cdcd3032201267
from unittest import mock from django.contrib.auth import models from django.contrib.auth.mixins import ( LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin, ) from django.contrib.auth.models import AnonymousUser from django.core.exceptions import PermissionDenied from django.http import HttpResponse...
1d1ecceddac98c3b54168b7daf32c0fa38b800e49bebc36e3e418d36e51f72e7
from django.contrib.auth import get_user, get_user_model from django.contrib.auth.models import AnonymousUser, User from django.core.exceptions import ImproperlyConfigured from django.db import IntegrityError from django.http import HttpRequest from django.test import TestCase, override_settings from django.utils impor...
ab001ef47d5e689e635f611113107781c98b7fbf8157c647dbe0cefcf0872cab
import sys from datetime import datetime, timedelta from types import ModuleType from django.conf import ( PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSG, Settings, settings, ) from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.core.exceptions imp...
cd61916d4426b019784016ca94c9e1b675f87d36bf9d22f9dd37d0e8c46faf6a
import builtins import getpass import os import sys from datetime import date from io import StringIO from unittest import mock from django.apps import apps from django.contrib.auth import get_permission_codename, management from django.contrib.auth.management import ( create_permissions, get_default_username, ) f...
3ccaf8245c65ba93c098d7e9ce378fac113d24eaaafaceb8d026d9a460353afc
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): ...
b445e7af43d5bcdc6da9603c46352741ca74496cefcb3147ee938b1b89125e0c
from django.contrib import admin from django.contrib.auth import views from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.urls import urlpatterns as auth_urlpatterns from django.contrib.messages.api import info...
fa56ca22bec38260fae51a35491318ea53b3d8d3b7418bdf53aff3536f6e59c4
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...
96698ee96d58b9f8699a48cbef222440f13ba04b6e9a9e6495c3fa67d460551a
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...
bce3957670b164e7b24369864dc1bb15216389ffd53238a8a94c4f3e7006a531
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...
8dd4480f0f0c6da7e88f472731cfc79d146639c3db44b56b4c7ba96507ca4302
from django.contrib.auth import HASH_SESSION_KEY from django.contrib.auth.middleware import AuthenticationMiddleware from django.contrib.auth.models import User from django.http import HttpRequest, HttpResponse from django.test import TestCase class TestAuthenticationMiddleware(TestCase): def setUp(self): ...
2484137da977bc7af2fe303a74d4c7dbbe0c2b7ae807d9708a618a1b6fe6325b
import os import shutil import sys import tempfile import threading import time import unittest from datetime import datetime, timedelta from io import StringIO from pathlib import Path from urllib.request import urlopen from django.core.cache import cache from django.core.exceptions import SuspiciousFileOperation fro...
487a0b8f8dc3901413b77cebe97d409e8a0a6496e85a0ec7ec54746ffcaddddc
""" Storing files according to a custom storage system ``FileField`` and its variations can take a ``storage`` argument to specify how and where files should be stored. """ import random import tempfile from pathlib import Path from django.core.files.storage import FileSystemStorage from django.db import models cl...
b9486756da123b4d47ceb6f4219d36555d4cb8445f5d778de748cd612982e231
import uuid from django.conf.urls import url as conf_url from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings from django.urls import NoReverseMatch, Resolver404, path, resolve, reverse from django.utils.deprecation import Remove...
75dd278a15e7185715c3f59598aecc9fc9cd36737cc44824bdd7daab7119646d
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...
9ea7eff7b7dbbe6b103b2c125c61cf6768648e645b5d0d1ece739e7b821a3ff9
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...
3bfa5f1e3ed8b1b945bb050f473968303465ebd4aed622757b16b2a0794e87d5
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...
508fa147c40314f8555e65c280a11a0f41327f138d49dfce1888e381c2f78c91
import re from django.conf import settings from django.contrib.sessions.backends.cache import SessionStore from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest, HttpResponse from django.middleware.csrf import ( CSRF_SESSION_KEY, CSRF_TOKEN_LENGTH, REASON_BAD_TOKEN, REASON...
5b7d40789b2e394b3573dd0dda9646fa1766a0fafeb6c3cc10ae4f9f6db4bdc0
from django.http import HttpRequest from django.middleware.csrf import _compare_masked_tokens as equivalent_tokens from django.template.context_processors import csrf from django.test import SimpleTestCase class TestContextProcessor(SimpleTestCase): def test_force_token_to_string(self): request = HttpReq...
3d03ca4a65d4f2e93166a7ec9c238e0244981b1d1bd4fe97f2e479509e5ceca8
""" Models can have a ``managed`` attribute, which specifies whether the SQL code is generated for the table on various manage.py operations. """ from django.db import models # All of these models are created in the database by Django. class A01(models.Model): f_a = models.CharField(max_length=10, db_index=Tru...
2c444c4fd5b8ee570e150b763eadbd7598698b36945e639f84fcf503a4079b3f
from django.apps import apps from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.core.exceptions import FieldDoesNotExist from django.db.models import ( CharField, Field, ForeignObjectRel, ManyToManyField, ) from django.db.models.options import EMPTY_RELATION_TREE,...