hash
stringlengths
64
64
content
stringlengths
0
1.51M
e4b04536e84ca7d39f77a44890ffcf15ee4984f97f1bfb053eba16d2df080f74
from unittest import mock from django.core.exceptions import ValidationError from django.db import IntegrityError, connection, models from django.db.models.constraints import BaseConstraint from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from .models import ChildModel, Product, UniqueConstraintP...
25c691af0ff96c6f4605e74ed7b5c46cfdddf08069e59050f7023ea29d02deb6
from django.db import models class Product(models.Model): price = models.IntegerField(null=True) discounted_price = models.IntegerField(null=True) class Meta: required_db_features = { 'supports_table_check_constraints', } constraints = [ models.CheckConstra...
33fce4977a4d24fa81b79752faefe816ff62ecdfa5ac366efc04aa54191286bc
import datetime import pickle import unittest import uuid from copy import deepcopy from unittest import mock from django.core.exceptions import FieldError from django.db import DatabaseError, connection, models from django.db.models import CharField, Q, TimeField, UUIDField from django.db.models.aggregates import ( ...
b27c25325ee97a249ee4f6314401ce41092bb3c88f051047fdab10905de708c8
""" Tests for built in Function expressions. """ from django.db import models class Author(models.Model): name = models.CharField(max_length=50) alias = models.CharField(max_length=50, null=True, blank=True) goes_by = models.CharField(max_length=50, null=True, blank=True) age = models.PositiveSmallInt...
e8bb7e8907fe9f264d0e25557bed85673095dc008e863bc1afa3fcfcf2b62d91
from django.core.exceptions import FieldError from django.test import TestCase from .models import ( BigChild, Child, ChildProxy, Primary, RefreshPrimaryProxy, Secondary, ) class AssertionMixin: def assert_delayed(self, obj, num): """ Instances with deferred fields look the same as normal ins...
48a2f7490d50a5de9e9717944ed26f57bb6ba760f88e44c4daff544b4d1e6740
import copy import json import os import pickle import unittest import uuid from django.core.exceptions import DisallowedRedirect from django.core.serializers.json import DjangoJSONEncoder from django.core.signals import request_finished from django.db import close_old_connections from django.http import ( BadHead...
1cedaddd7322aa55d36f17bd314b23b57a4b441569e2fea9a1df4942301aaec6
import gettext import os import re from datetime import datetime, timedelta from importlib import import_module import pytz from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import widgets from django.contrib.admin.tests import AdminSeleniumTestCase f...
f85e15f08f66009c4a60d5b9233627335054dda0e2332a099d26b0e04260af30
from django.db import migrations, models class Migration(migrations.Migration): initial = True operations = [ migrations.CreateModel( name='fakeinitialmodel', fields=[ ('id', models.AutoField(primary_key=True)), ('field', models.CharField(max_le...
7d60049efbcfe7b8fe60256478617d5169ffbae2e00653091ad5fd000444e20d
from django.db import migrations, models class Migration(migrations.Migration): initial = True operations = [ migrations.CreateModel( 'fakeinitialmodel', [ ('id', models.AutoField(primary_key=True)), ('field', models.CharField(max_length=20)), ...
428f6cd0118eea72e737b9b06e872c2e807913f53bc8934df78e94a192b69fe4
from datetime import date from django.forms import DateField, Form, SelectDateWidget from django.test import override_settings from django.utils import translation from django.utils.dates import MONTHS_AP from .base import WidgetTest class SelectDateWidgetTest(WidgetTest): maxDiff = None widget = SelectDate...
30685a56ea78fae68c7c3b4b2b3a4076641decdacbb6ec72caed05fa9168c060
import datetime from django.contrib.sites.models import Site from django.http import Http404 from django.template import TemplateDoesNotExist from django.test import RequestFactory, TestCase from django.test.utils import override_settings from django.views.defaults import ( bad_request, page_not_found, permission_...
7b2b57db7c5b7e3698ae7f5dc1a973723fe455491fb4f81e178398b4fb783bd3
""" ******** Models for test_data.py *********** The following classes are for testing basic data marshalling, including NULL values, where allowed. The basic idea is to have a model for each Django data type. """ from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.con...
b1dfcc9332d3e1806b14671b86168042762bb3b6e5080f80c24775f5d9e69b62
import operator from django import template from django.template.defaultfilters import stringfilter from django.utils.html import escape, format_html from django.utils.safestring import mark_safe register = template.Library() @register.filter @stringfilter def trim(value, num): return value[:num] @register.fi...
5c7e6541d37151071cf3057ad31e3cb859c51c6dd1e4b2d02ae00a0006647210
import copy import unittest from django.db import connection from django.test import SimpleTestCase @unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests') class TestDbSignatureTests(SimpleTestCase): def test_custom_test_name(self): saved_settings = copy.deepcopy(connection.settings_dict) ...
e5be435de0124cac35a8824aa359e1f00b16eea4d45bc9c09a899d3a7d3cd5e0
import copy 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 class TestDbSignatureTests(SimpleTestCase): def get_connection_copy(self):...
cbb7a439d66a3fe9d280ccc34cf3071473978544b630912cbd3779ce1f3d7904
import json import math import re from decimal import Decimal from django.contrib.gis.db.models import functions from django.contrib.gis.geos import ( GEOSGeometry, LineString, Point, Polygon, fromstr, ) from django.contrib.gis.measure import Area from django.db import NotSupportedError, connection from django.db....
06382302db2d6ae6631fdb1feddd6a778173afd2689bdf2ef4a31b379ede8f4b
import os import shutil import struct import tempfile from django.contrib.gis.gdal import GDAL_VERSION, GDALRaster from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.raster.band import GDALBand from django.contrib.gis.shortcuts import numpy from django.test import SimpleTestCase from...
8ce293bd6aa6c2615044c69626b0bf7ce5179ffb31e0387653fcdc9656ba7ba4
import datetime import decimal import unittest from django.db import connection, models from django.db.models import Avg from django.db.models.expressions import Value from django.db.models.functions import Cast from django.test import ( TestCase, ignore_warnings, override_settings, skipUnlessDBFeature, ) from .....
991f5ed65560aa1a24b53bc0fcc608a842d9fb01c47bf09a4353c08077f98084
""" Sphinx plugins for Django documentation. """ import json import os import re from docutils import nodes from docutils.parsers.rst import Directive from docutils.statemachine import ViewList from sphinx import addnodes from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.directives import CodeBlock fr...
66b5e59c03f50c8fb54a1be36f63eaecb7b32dfac20e6921235da4c262bf6fee
import builtins import collections.abc import datetime import decimal import enum import functools import math import re import types import uuid from django.conf import SettingsReference from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.utils import COMP...
efe5bbd8664da3cebc6e6c0c70a72d8e2987609a519cb5e292aa26d7dc370cac
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.expressions import Expression from django.db.models.lookups import Lookup, Transform from django.db.models.sql.query import Query from django.uti...
d2e38cd8f33ae3bc277de071028aebb9847f5293fded00355e766f211bfa5f7c
""" 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...
a141d85ded4c2d6cba09db41cacd28e288bf22525352011ccc64cc6cce011a08
import datetime import decimal import enum import functools import math import os import re import uuid from unittest import mock import custom_migration_operations.more_operations import custom_migration_operations.operations from django import get_version from django.conf import SettingsReference, settings from dja...
df465cc89bee217df3a0ef32e455037839fba7568d6bf5241505c9ab5877d014
import tempfile import unittest 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, Poin...
7fce9bf3b86b52c30be6c0ad9e935eb0d6ff4562be5c2cafd1810848439ce148
"""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...
c2e75962c2b87de7cb15a16303c57e11445c31ec6e475b172796cfe4770dad69
""" Helper functions for creating Form classes from Django models and database field objects. """ from itertools import chain from django.core.exceptions import ( NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError, ) from django.forms.fields import ChoiceField, Field from django.forms.forms impor...
87533f33aad54161239238e914b7222553166b64ddd6163fe4428e023fec3ab4
""" HTML Widget classes """ import copy import datetime import warnings from collections import defaultdict from itertools import chain from django.conf import settings from django.forms.utils import to_current_timezone from django.templatetags.static import static from django.utils import datetime_safe, formats from...
9600bccb21582a64f650d91dfc274e29582c1dcd8b1798cab29a8770e3b6e038
""" Form classes """ import copy from django.core.exceptions import NON_FIELD_ERRORS, ValidationError from django.forms.fields import Field, FileField from django.forms.utils import ErrorDict, ErrorList from django.forms.widgets import Media, MediaDefiningClass from django.utils.datastructures import MultiValueDict f...
9c9048a19de76f7c2aff9cd269bf419579d3c98754177f5f00445a02668ea689
from pathlib import Path import jinja2 from django.conf import settings from django.template import TemplateDoesNotExist, TemplateSyntaxError from django.utils.functional import cached_property from django.utils.module_loading import import_string from .base import BaseEngine class Jinja2(BaseEngine): app_dir...
6caaedab7f31b30e7a21c69749fe5c5bba808b31622e0519407bfacaaa2cb682
from contextlib import contextmanager from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.test import modify_settings from django.test.selenium import SeleniumTestCase from django.utils.deprecation import MiddlewareMixin from django.utils.translation import gettext as _ class CSPMiddl...
ea7cb7df77ced83931c47779207b1f9a11a055ca59d76478f203ccaab7062c49
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...
a2b5464d7807c7e8477f413813c31493f971030828307df19652cd4d92b102d6
import sys from django.core.management.color import color_style from django.db import migrations, transaction from django.db.models import Q from django.db.utils import IntegrityError WARNING = """ A problem arose migrating proxy model permissions for {old} to {new}. Permission(s) for {new} already existed...
0c20391843e63e79c1ff765fc888c2508d9e157139bc8dc1b714c2e72910765b
from pathlib import Path from unittest import mock, skipIf from django.template import TemplateSyntaxError from django.test import RequestFactory from .test_dummy import TemplateStringsTests try: import jinja2 except ImportError: jinja2 = None Jinja2 = None else: from django.template.backends.jinja2 ...
0347a990110458df30e83359aaf3c22258e1ba583ae8b3c667dbf37676c634d3
from importlib import import_module from django.apps import apps from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.db import connection, connections from django.test import TransactionTestCase from django.test.utils import captured_stdout fr...
e27ed3e2b2c32af9af91b2e5612161768223d966d16da7dc7d4f3885fdfec5a3
import datetime import os import re import unittest from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse import pytz from django.contrib.admin import AdminSite, ModelAdmin from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.models import ADDITION, DELETIO...
c7498edb83942d364d5a913cb514a1cb0c97cbf61055e8a5481f12f1c6a07a1f
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 import get_fix...
e78e13906301fe21c41828ae76d24eb3bbdb482713aba5205b797c40f6c0a5f1
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 ...
b710ff0aa51d0e0ef91bbfe9cf91fa0578b1bf4ad011b62a9eca35c78ea5b8f8
from django.contrib.admin import ModelAdmin, TabularInline from django.contrib.admin.helpers import InlineAdminForm from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import Requ...
e1cac3b1b7cff4a4a76ff5733c7b80f1583794fe2fc04e4e2e5e7f0bfada7ee8
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...
2346f845868a05acf18ff66531e2d0c35e94e619c223336e4d65e20ce9cc8fd0
import gettext import os import re from datetime import datetime, timedelta from importlib import import_module import pytz from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import widgets from django.contrib.admin.tests import AdminSeleniumTestCase f...
992e552f6cf8ad62c56e37f65ba0086b4f1d6aa24b9d59e1419323a19312b093
#!/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.' ...
08532e651aecb54184d61e34a1d0e758135c32c66ef4be8cc7f5206d47f08d7a
import ctypes import itertools import logging import multiprocessing import os import pickle 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.test import SimpleTestCase, TestCase fro...
2722087ce34f61b6eb929550bbd75113d771120f61c8c57e7f067ccce303e066
import logging 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.dom.minidom import Node, parseString from dj...
8eb952161e149e63092ea44935d24a800ff69e6db815820450133490bd9157cb
#!/usr/bin/env python # When the django-admin.py deprecation ends, remove this script. import warnings from django.core import management try: from django.utils.deprecation import RemovedInDjango40Warning except ImportError: raise ImportError( 'django-admin.py was deprecated in Django 3.1 and removed ...
cdeb1622416ae2500e3440e90d5b08c704c3574c071aaf9db8a41018c773874c
""" Functions for working with "safe strings": strings that can be displayed safely without further escaping in HTML. Marking something as a "safe string" means that the producer of the string has already turned characters that should not be interpreted by the HTML engine (e.g. '<') into the appropriate entities. """ ...
b0545429bad39d7a39b8644d23d447399d5b6f474514e81ee54cd3eeac06c90f
import asyncio import functools import os from django.core.exceptions import SynchronousOnlyOperation def async_unsafe(message): """ Decorator to mark functions as async-unsafe. Someone trying to access the function while in an async context will get an error message. """ def decorator(func): ...
bbe54d2137ac723ce1a12d7aa48199bbd1c0b9af751b3d875dfdbb2cf28789dd
""" This is the Django template system. How it works: The Lexer.tokenize() method converts a template string (i.e., a string containing markup with custom template tags) to tokens, which can be either plain text (TokenType.TEXT), variables (TokenType.VAR), or block statements (TokenType.BLOCK). The Parser() class ta...
391768ef2f1ad98144d045172bb2e683a67d48db371d46d55f82667b507c33a3
""" 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...
4c00d94b8d6fff2fd87e28baabc43f6a2205962b1af7e2de5344cc3c17a1c0da
import cgi import codecs import copy from io import BytesIO from itertools import chain from urllib.parse import quote, urlencode, urljoin, urlsplit from django.conf import settings from django.core import signing from django.core.exceptions import ( DisallowedHost, ImproperlyConfigured, RequestDataTooBig, ) from ...
55754f0de3232b3ad9069ca7002e20a3124a0acc9f257ad2349624fe633eaf68
""" The main QuerySet implementation. This provides the public API for the ORM. """ import copy import operator import warnings from collections import namedtuple from functools import lru_cache from itertools import chain from django.conf import settings from django.core import exceptions from django.db import ( ...
a66cb32cf16eddc664ec7e99c2e18cfc8c9a02c7ce72595274dbe81a7d00f994
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. """ try: if isinstance(model, tuple): ...
82f4effe16e8bd01e203441620b013814ccabb47b274ca1e3e3bd27cc42ad741
""" 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 import warnings from collection...
58814a60d618e34172777b988cbc98e3292a08db95fbc10a4d3a7a920e496f02
""" Accessors for related objects. When a field defines a relation between two models, each model class provides an attribute to access related instances of the other model class (unless the reverse accessor has been disabled with related_name='+'). Accessors are implemented as descriptors in order to customize acces...
aa26c4d9acdd73a29b3841435ea20f4ca4bb6bb34b0ff28e46808fd71516a5b1
""" Create SQL statements for QuerySets. The code in here encapsulates all of the SQL construction so that QuerySets themselves do not have to (and could be backed by things other than SQL databases). The abstraction barrier only works one way: this module has to know all about the internals of models in order to get ...
37beb2110887d82d533172382847c45fffa3dacd8852c77d74f0fb9343010849
import collections import re from functools import partial from itertools import chain from django.core.exceptions import EmptyResultSet, FieldError from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import OrderBy, Random, RawSQL, Ref, Value from django.db.models.functions import Cast...
509974ce2dc5e4ea8fcfcc9903c94777226a3ecb192147b4119f89977930f3f3
import copy import threading import time import warnings from collections import deque from contextlib import contextmanager import _thread import pytz from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import DEFAULT_DB_ALIAS from django.db.backends import utils f...
5dd16dfb1182262e60fb758904505eabd4cea5eca78abe5103d0565c833cf60c
""" PostgreSQL database backend for Django. Requires psycopg 2: http://initd.org/projects/psycopg2 """ import asyncio import threading import warnings from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import connections from django.db.backends.base.base import Ba...
d1088728855733592155821ebfdb784c8d75657f224a59157cb89e51bc04f91a
"Misc. utility functions/classes for admin documentation generator." import re from email.errors import HeaderParseError from email.parser import HeaderParser from inspect import cleandoc from django.urls import reverse from django.utils.regex_helper import _lazy_re_compile from django.utils.safestring import mark_sa...
0a1031f57dfb712863d795b8823f69353ae5ab062b6828bc516d41e5a5ad091b
import inspect from importlib import import_module from inspect import cleandoc from pathlib import Path from django.apps import apps from django.conf import settings from django.contrib import admin from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admindocs import utils from...
3baaeae3f50b77f4023a9f3217ca45ea479ce603d9dc8e4f5c103e8bfbb1a450
import inspect import re from django.apps import apps as django_apps from django.conf import settings from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.middleware.csrf import rotate_token from django.utils.crypto import constant_time_compare from django.utils.module_loading import i...
39982069d4b77a3f7676f9e7519bb1d4985735fa8ed5683ce91f638c51ccbbda
from contextlib import contextmanager from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.test import modify_settings from django.test.selenium import SeleniumTestCase from django.utils.deprecation import MiddlewareMixin from django.utils.translation import gettext as _ class CSPMiddl...
18efebba5290e8a7fb4961ba29ff3b8957e6123616582b467d45646d522be988
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...
5438f9aa92184d36d397e7c3e4aa892c28055ed7860d0f88c8362bc3c635b3bc
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 .utils import AttributeSetter __all__ = [ 'RangeField', 'IntegerRangeField', 'BigIntegerRangeField', 'DecimalRangeField...
9f3a18bc240e483cc93e8e85565c848d402c618689ce28ba66ecd34378f90c4c
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, RED...
e08cf646699ce7abf62eb4cbf444d4407ca6980986ed12432a9986171ac6553c
from datetime import date from unittest import mock from django.contrib.auth import ( BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user, signals, ) from django.contrib.auth.backends import BaseBackend, ModelBackend from django.contrib.auth.hashers import MD5PasswordHasher from django.contrib.auth.models imp...
adfdacb19bc4f9bda282998bc366d90f8298c5ac8f5344997b87cf2fee976206
import uuid from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings from django.urls import Resolver404, path, resolve, reverse from .converters import DynamicConverter from .views import empty_view included_kwargs = {'base': b'he...
b115a2d1c7bdae51f2bce4c3ce5c6528858e2ffdea45a9ecc429393eac4af5e1
from django.urls import include, path, re_path from . import views urlpatterns = [ path('articles/2003/', views.empty_view, name='articles-2003'), path('articles/<int:year>/', views.empty_view, name='articles-year'), path('articles/<int:year>/<int:month>/', views.empty_view, name='articles-year-month'), ...
8e2e4fa2f377c6760e23520596fce79e5dc0e0e50ad3c74c610bd321d1c95744
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...
a84d8ab9c645936b332f0626cab86d97054e9283444a4dcfe1e865940e8417d0
from django.db import models class Country(models.Model): 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.CASCADE) class EUCity(models.Mode...
fd686e8a61c8b368197a352952653ec9ecf362454973737a2ccb5e2c2a9f12d3
import datetime import os import re import unittest from unittest import mock from urllib.parse import parse_qsl, urljoin, urlparse import pytz from django.contrib.admin import AdminSite, ModelAdmin from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.models import ADDITION, DELETIO...
60b5a5ed8e22df661efe38a50473a4139fc7f072d95104280c0368c53f8462d4
import datetime import os import tempfile from io import StringIO from wsgiref.util import FileWrapper from django import forms from django.contrib import admin from django.contrib.admin import BooleanFieldListFilter from django.contrib.admin.views.main import ChangeList from django.contrib.auth.admin import GroupAdmi...
11021e309bcac8cc95ee4e035bb43649d92706d1c405a8585b36c1e2f13dda0d
from django.urls import include, path from . import admin, custom_has_permission_admin, customadmin, views from .test_autocomplete_view import site as autocomplete_site urlpatterns = [ path('test_admin/admin/doc/', include('django.contrib.admindocs.urls')), path('test_admin/admin/secure-view/', views.secure_v...
e8972a6935f546872a8d85852fc140ae635f7b678bcc2449a7ceac4c080c0b36
import json from contextlib import contextmanager from django.contrib import admin from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.admin.views.autocomplete import AutocompleteJsonView from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import...
36e6ab5d779761ef11435e54c09d564f8850a408f0bcaee34854082093b30f81
import unittest from django.contrib.admindocs.utils import ( docutils_is_available, parse_docstring, parse_rst, ) from django.test.utils import captured_stderr from .tests import AdminDocsSimpleTestCase @unittest.skipUnless(docutils_is_available, "no docutils installed.") class TestUtils(AdminDocsSimpleTestCase...
7e81beaf3e6fd33b54a7aa9103c7f552eaa6753e43c502d158f1e7fcebaff594
import datetime import json from decimal import Decimal from django import forms from django.core import exceptions, serializers from django.db.models import DateField, DateTimeField, F, Func, Value from django.http import QueryDict from django.test import override_settings from django.test.utils import isolate_apps f...
d92e8a9c365084ac4971782adcf31f7bc1c24ed1f00730de680fa7a14e4d6857
from django.core.serializers.json import DjangoJSONEncoder from django.db import models from .fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField, HStoreField, IntegerRangeField, JSONField, SearchVectorFi...
80b0609951166bd0f9da8dcfebcfad01ed05bc9f7b23a3f0d67d8611fa51d017
import os from argparse import ArgumentParser from contextlib import contextmanager from unittest import TestSuite, TextTestRunner, defaultTestLoader, skipUnless from django.db import connections from django.test import SimpleTestCase from django.test.runner import DiscoverRunner from django.test.utils import captured...
efbb74c12606bfc06183571572c6a10f7fe7cf0e0a769c3dcf06cdbd77a1fae5
from io import BytesIO from itertools import chain from urllib.parse import urlencode from django.core.exceptions import DisallowedHost from django.core.handlers.wsgi import LimitedStream, WSGIRequest from django.http import HttpRequest, RawPostDataException, UnreadablePostError from django.http.multipartparser import...
656140c673989f8ce67dc23b21489c46412fea77742d1dc9149d116e71fbdd88
from datetime import date, datetime from operator import attrgetter from django.db import IntegrityError from django.test import TestCase from .models import ( CustomMembership, Employee, Event, Friendship, Group, Ingredient, Invitation, Membership, Person, PersonSelfRefM2M, Recipe, RecipeIngredient, Rela...
f5a73bdf74b54acf28b3db7cfe18e1b3822072fcc91dd1b12a123601d5fc74ad
from django.contrib.admin import ModelAdmin, TabularInline from django.contrib.admin.helpers import InlineAdminForm from django.contrib.admin.tests import AdminSeleniumTestCase from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.test import Requ...
bf8b4c1824f61ec9f35b987d43f5322a5378f36038534e92d0829fe0053fda83
""" 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...
0d8aecfce52eb06f8832ebd4894b31d5ec06a85cf23d257cc55c911f8a5905d6
import os import subprocess import sys import django from django.test import SimpleTestCase class DeprecationTests(SimpleTestCase): DEPRECATION_MESSAGE = ( b'RemovedInDjango40Warning: django-admin.py is deprecated in favor of ' b'django-admin.' ) def setUp(self): script_dir = os....
c2fa6f54f4c2055c8e5e924e6197fe3251c34f1c9e34f5b6f3f28e03744c41fc
import datetime from unittest import mock, skipIf, skipUnless from django.core.exceptions import FieldError from django.db import NotSupportedError, connection from django.db.models import ( BooleanField, Case, F, Func, OuterRef, Q, RowRange, Subquery, Value, ValueRange, When, Window, WindowFrame, ) from djang...
51a266e777b015d48c034da68e471031bfdabf07d39b9190f90351852b7e284d
import datetime import re import sys from contextlib import contextmanager from unittest import SkipTest, skipIf from xml.dom.minidom import parseString import pytz from django.contrib.auth.models import User from django.core import serializers from django.db import connection from django.db.models import F, Max, Min...
597bdcb4f33d83a9f91375384ed6a16fbbefd34656cea15ef5d516fe9f3963ac
from unittest import mock from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ObjectDoesNotExist from django.db import connection from django.db.models import Prefetch, QuerySet from django.db.models.query import get_prefetcher, prefetch_related_objects from django.db.models.s...
a10399f350aa3a3fa4b0556eb87ab0c60166ea9ed1329fa6a4880b05e159794b
import time import unittest from datetime import date, datetime from django.core.exceptions import FieldError from django.db import connection, models from django.test import SimpleTestCase, TestCase, override_settings from django.test.utils import register_lookup from django.utils import timezone from .models import...
fe0150771354711e26b9b666c01a5590dbd7873d7b81003fee97f2621c1a543a
import os import sys from unittest import mock, skipIf from asgiref.sync import async_to_sync from django.core.exceptions import SynchronousOnlyOperation from django.test import SimpleTestCase from django.utils.asyncio import async_unsafe from .models import SimpleModel @skipIf(sys.platform == 'win32' and (3, 8, 0...
cb23a5d3ce9177bfc32b7026e6611bab1a90c96265ee091571986e1d6b51fc20
import gettext import os import re from datetime import datetime, timedelta from importlib import import_module import pytz from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import widgets from django.contrib.admin.tests import AdminSeleniumTestCase f...
0f22b4ee495a36dcad1da2ed5570a6ce0abea2de6e05f749a0f2a41b18e17844
import sys from unittest import TestCase class WriteToStdoutStderrTestCase(TestCase): def test_pass(self): sys.stderr.write('Write to stderr.') sys.stdout.write('Write to stdout.') self.assertTrue(True) def test_fail(self): sys.stderr.write('Write to stderr.') sys.stdo...
70188943a665cc4151510e175c3fbdb8ba694690fb2577355902a4229a679686
from django.core.serializers.json import DjangoJSONEncoder from django.db import migrations, models from ..fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, DateRangeField, DateTimeRangeField, DecimalRangeField, EnumField, HStoreField, IntegerRangeField, JSONField, S...
c2684f689903da951906e5717e8f6fc08fbe7d88277357425dcef78926e5bfdd
""" 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...
8985f3be97c38f1fde439e273fb2f0b3cd26f0326fa046bdf8d960751452e377
""" 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 ####...
b175058cd0f84c5981a8982831ec7520c8680c6cc3e54dbb887a8db4831adeb9
""" termcolors.py """ color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white') foreground = {color_names[x]: '3%s' % x for x in range(8)} background = {color_names[x]: '4%s' % x for x in range(8)} RESET = '0' opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conce...
3670ee81939b61aa2fe28eb8443814ae86c40709efa55669c7948ec32de9dd67
"""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....
059077e4e22b05b1425ceca7dd27f7ab6ff3e1c7812bd9867ba3238a5e5c2e9b
""" Helper functions for creating Form classes from Django models and database field objects. """ from itertools import chain from django.core.exceptions import ( NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError, ) from django.forms.fields import ChoiceField, Field from django.forms.forms impor...
b8a45e4b78bb840fad9425110141b38f414a68bea55bfad88d8f88f3b8aa0c6a
""" HTML Widget classes """ import copy import datetime import warnings from collections import defaultdict from itertools import chain from django.conf import settings from django.forms.utils import to_current_timezone from django.templatetags.static import static from django.utils import datetime_safe, formats from...
1098cceaaa7a84d9a3b0e71e2a4e829bacd2e6ecc59240dd56dbc10b429b47ce
import datetime import json import mimetypes import os import re import sys import time 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.core.exceptions import DisallowedRedir...
46c841ff151b6e4e58e94566c6d39ed998749d4b6e6a9dbbdc35ee0812ada93a
import cgi import codecs import copy from io import BytesIO from itertools import chain from urllib.parse import quote, urlencode, urljoin, urlsplit from django.conf import settings from django.core import signing from django.core.exceptions import ( DisallowedHost, ImproperlyConfigured, RequestDataTooBig, ) from ...
643d11cb4536de7a521df5f8100779327dd707fe71a6fcb5fea31cacf3a87938
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.safestring import SafeData, mark_safe ...
45b2bf0cefd583fd76d2ed3eb44a96d4171362a72065171c60cb96f97ec98e74
import functools from django.http import HttpRequest def sensitive_variables(*variables): """ Indicate which variables used in the decorated function are sensitive so that those variables can later be treated in a special way, for example by hiding them when logging unhandled exceptions. Accept ...