hash
stringlengths
64
64
content
stringlengths
0
1.51M
9cde7a1892edaf15b5cdf13e54c89031c0946a79a52f7cb194e4f48e36aad481
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...
b180249ea34d9f5a75f8ffe294e420275bb23d12ec4c6c6aa444ad7652ddfd2f
""" Test URLs for auth admins. """ from django.contrib import admin from django.contrib.auth.admin import GroupAdmin, UserAdmin from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns from django.urls import path # Create a silo'd admin site for just the user/group admins. ...
883d05386d8bf0a6dfef1473e3a380c04856f8823a740fd1367c2eb32813fdb3
import re from django.contrib.auth.views import ( INTERNAL_RESET_SESSION_TOKEN, PasswordResetConfirmView, ) from django.test import Client def extract_token_from_url(url): token_search = re.search(r'/reset/.*/(.+?)/', url) if token_search: return token_search.group(1) class PasswordResetConfirm...
c3b4a7e10d6c8bff1fef38375c373a01f5ddcf3c42c1c3d854d2827eb5cb31ba
from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin from django.urls import path site = admin.AdminSite(name='custom_user_admin') class CustomUserAdmin(UserAdmin): def log_change(self, request, object, message): # LogEntry.user c...
3975a4701f0d7051878d48ff2aefba64515347d4d974cbf6d4ffcb47cb90c986
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...
f6a2bd87a692998e4f612748221aed4f322b4778d2c9940d740dd40e6077c38a
import os from django.contrib.auth import validators from django.contrib.auth.models import User from django.contrib.auth.password_validation import ( CommonPasswordValidator, MinimumLengthValidator, NumericPasswordValidator, UserAttributeSimilarityValidator, get_default_password_validators, get_password_v...
2c70ea9aad3b0a4c858c3b3cdf5795941834008cc406c3f7800e7a4cfa726af9
import datetime import re from unittest import mock from django import forms from django.contrib.auth.forms import ( AdminPasswordChangeForm, AuthenticationForm, PasswordChangeForm, PasswordResetForm, ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm, UserChangeForm, UserCreationForm, ...
7ffe158de1a2b49c693e13922660c5967d347280aec285487ad7d8f3ad943fee
from django.contrib.auth import authenticate from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.views import ( PasswordChangeDoneView, PasswordChangeView, PasswordResetCompleteView, PasswordResetDoneView, PasswordResetView, ) f...
7b7f65bb5cec31b1e9fe20d6ee5af2145b88f70629e1c63a1cc495daa8a2c589
from django.conf import settings from django.contrib.auth import models from django.contrib.auth.decorators import login_required, permission_required from django.core.exceptions import PermissionDenied from django.http import HttpResponse from django.test import TestCase, override_settings from django.test.client impo...
bb3bf6f70a11047817c59647f5200ab34ef4ffd565a82d46363093d44a04c198
import warnings from django.contrib.auth.backends import RemoteUserBackend from django.contrib.auth.models import User from django.test import TestCase, modify_settings, override_settings class CustomRemoteUserBackend(RemoteUserBackend): """Override configure_user() without a request argument.""" def configu...
403884f3f0a1de0383ebde4db99f2e811050715b23fadb4bd5baa3f12ad21895
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...
644b78929a33cb083c3255e78c6bd79be0891ed35886eed3df3b64d22bfdac4d
import os import shutil import sys import tempfile import threading import time import unittest from datetime import datetime, timedelta from io import StringIO from urllib.request import urlopen from django.core.cache import cache from django.core.exceptions import SuspiciousFileOperation from django.core.files.base ...
61f9dcb02b8016ccf052678913d624b5795fd32cf21086e75fbbd1897be934da
from django.http import HttpResponse from django.urls import path urlpatterns = [ path('', lambda req: HttpResponse('example view')), ]
76c7b146ce25538f05cbfc31c6e93962bd7545e632e85bbc60eae35ac99021dd
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...
59ed49dec9364f228d5d5a2041e9ba783fa2b95919423e361fc5d6f4f4589656
from django.urls import re_path from . import views urlpatterns = [ re_path(r'^more/(?P<extra>\w+)/$', views.empty_view, name='inner-more'), ]
fbe00930612a5d70523785e4e0b646d691d57792899c0d0608e8cc33389afd53
from django.urls import include, path, register_converter from . import converters, views register_converter(converters.Base64Converter, 'base64') subsubpatterns = [ path('<base64:last_value>/', views.empty_view, name='subsubpattern-base64'), ] subpatterns = [ path('<base64:value>/', views.empty_view, name=...
5b9d859685d9fb555c494557936b65a20d378e570d57bb64e85552c6a8f39a80
from django.urls import include, path from . import views urlpatterns = [ path('extra/<extra>/', views.empty_view, name='inner-extra'), path('', include('urlpatterns.more_urls')), ]
29cb10eb39367bdd0547b96f589527f3494cb977f225a5a95654c92b92059c3e
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'), ...
8dfa86e5c680f993bc6e142580933669af7a71bb9a9e19acc6a4fb56d34e0a67
from django.http import HttpResponse def empty_view(request, *args, **kwargs): return HttpResponse()
b11d202c55f229beed2e0a8c53a0cb3c0ec06068f8149ef8cb04b847a2af77f7
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...
c382c9004da98a8e773899a3d48477f444cd559ee1c5ec8232e92c03257850f6
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 from django.middleware.csrf import ( CSRF_SESSION_KEY, CSRF_TOKEN_LENGTH, REASON_BAD_TOKEN, REASON_NO_CSRF_COOKI...
b4dd4fcfaccd565b4e4061dc5c82a871f394864c2df5bb5ed4bb1763a09e0018
from django.apps import apps from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.core.exceptions import FieldDoesNotExist from django.db.models.fields import CharField, Field, related from django.db.models.options import EMPTY_RELATION_TREE, IMMUTABLE_WARNING from djan...
c2fd4c8a3410c4cc58b75affb4e42632c59945319adec41288da38ccf147e876
import datetime import re from decimal import Decimal from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( Avg, Count, DecimalField, DurationField, F, FloatField, Func, IntegerField, Max, Min, Sum, Value, ) from django.db.models.expressions import Case, ...
7d4ff540d216ecd18c039847502ca8d649627d4a87f634efa13f8ea36b3388d4
import datetime from decimal import Decimal from django.db.models import ( Avg, Case, Count, F, OuterRef, Q, StdDev, Subquery, Sum, Variance, When, ) from django.test import TestCase from django.test.utils import Approximate from .models import Author, Book, Publisher class FilteredAggregateTests(TestCase): ...
48375fa63058f83f8597b95947c80463b275afaa4f87626567d39f9b0d608817
""" Regression tests for proper working of ForeignKey(null=True). Tests these bugs: * #7512: including a nullable foreign key reference in Meta ordering has unexpected results """ from django.db import models # The first two models represent a very simple null FK ordering case. class Author(models.Model): n...
45632f518c4f5995d70f335a925f18d06215bbf04899e4df67dc887c6008d938
from django.core.exceptions import FieldError from django.db.models import FilteredRelation from django.test import SimpleTestCase, TestCase from .models import ( AdvancedUserStat, Child1, Child2, Child3, Child4, Image, LinkedList, Parent1, Parent2, Product, StatDetails, User, UserProfile, UserStat, UserSt...
b702e8629dd348f0bc29c09c5b2143e1867e895e5a4d442ec7149d31778f06df
from django.db import IntegrityError, connections, transaction from django.test import TestCase, skipUnlessDBFeature from .models import Car, PossessedCar class TestTestCase(TestCase): @skipUnlessDBFeature('can_defer_constraint_checks') @skipUnlessDBFeature('supports_foreign_keys') def test_fixture_tear...
b64e86283376ea2c2e5cea7ddad0dc5da7144d3ab888d7c435d55157fbe280df
import os import unittest import warnings from io import StringIO from unittest import mock from django.conf import settings from django.contrib.staticfiles.finders import get_finder, get_finders from django.contrib.staticfiles.storage import staticfiles_storage from django.core.exceptions import ImproperlyConfigured ...
0bae14e95a95acec4d6a7d9d0d0f879dd2408655eb39669b5752f955d4885f73
from django.urls import path from . import views urlpatterns = [ path('test_utils/get_person/<int:pk>/', views.get_person), path('test_utils/no_template_used/', views.no_template_used, name='no_template_used'), ]
9d37fac5e7c7fbc860141a5fb430af2e24d61cab8d838bdef92d0f28a18d17b5
from django.db import connections from django.db.utils import DEFAULT_DB_ALIAS from django.test import SimpleTestCase, TestCase, TransactionTestCase from django.utils.deprecation import RemovedInDjango31Warning class AllowDatabaseQueriesDeprecationTests(SimpleTestCase): def test_enabled(self): class Allow...
672e587040b7377e9b467ff9349132ba111425520ceadbc0b80a700348010ee8
from unittest import mock from django.db import connections from django.test import TestCase, TransactionTestCase, override_settings from .models import Car class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase): """ TransactionTestCase._fixture_teardown() inhibits the post_migrate signal ...
4627a86d125285d6fd6e11c0d81a525405346442666768037c6261a25c2fc893
from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.template import Context, Template from .models import Person def get_person(request, pk): person = get_object_or_404(Person, pk=pk) return HttpResponse(person.name) def no_template_used(request): template = ...
20c22f72bba427c86f30d8df2bd36f7ab9749a4bf196e121459db28d69ffac7e
""" A second, custom AdminSite -- see tests.CustomAdminSiteTests. """ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.http import HttpResponse from django.urls import path from . import admin as base_admin, forms, models class A...
a819e9ab19315af7eec47d792082ec4cc6f0ea8da186d5036d8d1e0bdde5cd9e
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...
ab984fb9506f2a1fd33d2dcc2605fe6444d39df5a629477cb17ffabb377f32c9
import datetime import os import tempfile import uuid from django.contrib.auth.models import User from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.core.fil...
60382c7b8384803a1afa577ec97994e96a9a2c8fbb52815a3e8e83f29b577626
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...
24decb81653cd2666f4c150d87aba268b691da33969044ceebd9c65de6bb8340
import json from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.contrib.admin.views.main import IS_POPUP_VAR from django.contrib.auth.models import Permission, User from django.core import mail from django.template.loader import render_to_string from django.template.response import TemplateRespon...
251ec9d1033b5f2d577368142cbdff904e83a30e8bf25d62c873f23427dfa73a
from django.contrib.admin.models import LogEntry from django.contrib.auth.models import User from django.test import TestCase, override_settings from django.urls import reverse from .models import City, State @override_settings(ROOT_URLCONF='admin_views.urls') class AdminHistoryViewTests(TestCase): @classmethod...
5044e3f36dece595d7652c1c99d9a3096deeafde0f2884637e72cc6848cea053
from unittest import mock from django.contrib import admin from django.contrib.auth.models import User from django.db import connections from django.test import TestCase, override_settings from django.urls import path, reverse from .models import Book class Router: target_db = None def db_for_read(self, mo...
0dee5c4f1bf22e68929bbadfa61d8dcf1f8c98ab40200c97ea879fa2592b1243
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...
b62d45108844b3f1cc648b2946a50cbe1184cb7b0a388ed0137491f0592aad5f
from django.contrib import admin from django.contrib.admin.actions import delete_selected from django.contrib.auth.models import User from django.test import SimpleTestCase, TestCase, override_settings from django.test.client import RequestFactory from django.urls import path, reverse from .models import Article site...
572290548c3a3da5ed4f67be80d442f0540c971f3b3a6a7ee07225ac68d970cb
import datetime from django.contrib.admin import ModelAdmin from django.contrib.admin.templatetags.admin_list import date_hierarchy from django.contrib.admin.templatetags.admin_modify import submit_row from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.test import R...
c514bd2f922cc02502e94f2c68810925a9939af33528f573a8d29a96e11ae401
import datetime import pickle from django.db import models from django.test import TestCase from django.utils.version import get_version from .models import Container, Event, Group, Happening, M2MModel class PickleabilityTestCase(TestCase): @classmethod def setUpTestData(cls): Happening.objects.crea...
96dec105dbff7d91418acadb25dbf7e8796207bce24c779fd336e73fbce0cb4f
from django.test import TestCase from .models import ( Event, Movie, Package, PackageNullFK, Person, Screening, ScreeningNullFK, ) # These are tests for #16715. The basic scheme is always the same: 3 models with # 2 relations. The first relation may be null, while the second is non-nullable. # In some cases, Dja...
65e2b21769cddc2e3af6027525a554472ecb98be58acaf7f6164fcffd9f962a7
import datetime import sys import unittest from django.contrib.admin import ( AllValuesFieldListFilter, BooleanFieldListFilter, ModelAdmin, RelatedOnlyFieldListFilter, SimpleListFilter, site, ) from django.contrib.admin.options import IncorrectLookupParameters from django.contrib.auth.admin import UserAdmin fr...
ed86efb3520c04da103b689281a41bf561edc67189d57a5792b2400e0beb88e2
from django.apps import apps from django.apps.registry import Apps from django.conf import settings from django.contrib.sites import models from django.contrib.sites.management import create_default_site from django.contrib.sites.middleware import CurrentSiteMiddleware from django.contrib.sites.models import Site, clea...
0da036cfc6298f084e2df2171a50c168c8fa5aac3a5f50e4f4e201f6dffdae73
from django.core.exceptions import FieldError from django.test import TestCase from .models import Article, Author class CustomColumnsTests(TestCase): @classmethod def setUpTestData(cls): cls.a1 = Author.objects.create(first_name="John", last_name="Smith") cls.a2 = Author.objects.create(firs...
a68d4b04cf6f77e1a1ff35cf9a5e2ffeb8c62f4ce2680f18a8b87fdd3936980f
""" Custom column/table names If your database column name is different than your model attribute, use the ``db_column`` parameter. Note that you'll use the field's name, not its column name, in API usage. If your database table name is different than your model name, use the ``db_table`` Meta attribute. This has no ...
20b1972f466fccfa10aee0787d801b5e3d157eb4eebfce5573a029ad976baf54
import logging from contextlib import contextmanager from io import StringIO from admin_scripts.tests import AdminScriptTestCase from django.conf import settings from django.core import mail from django.core.exceptions import PermissionDenied from django.core.files.temp import NamedTemporaryFile from django.core.mana...
d914b3c648cc87db7001e8affb99704e3223dea5acd1a741664d09de15db12f3
from django.conf.urls.i18n import i18n_patterns from django.http import HttpResponse from django.urls import path urlpatterns = i18n_patterns( path('exists/', lambda r: HttpResponse()), )
4e313eda6360a35ea750c1acfe65522d89f544e45d223151893a83871b928009
from django.urls import path from . import views urlpatterns = [ path('innocent/', views.innocent), path('redirect/', views.redirect), path('suspicious/', views.suspicious), path('suspicious_spec/', views.suspicious_spec), path('internal_server_error/', views.internal_server_error), path('unca...
d560502da94d4cd37780bbab735ac7288d4d168652311f74d255de93bf2e6102
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 =...
a580fdd3ac6b8ca5d777769968d2e3ca19ee2ca8275a26c2a5fb6f0d821a1b18
import datetime import pickle from decimal import Decimal from operator import attrgetter from unittest import mock from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( Avg, Case, Count, DecimalField...
ef1cad99e792cef1903fa2940f7af79a67cf4c80ab991d8d7afd46023eccf691
from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError from django.db import IntegrityError from django.db.models import Q from django.test import SimpleTestCase, TestCase from .models import ( AllowsNullGFK, Animal, Carrot, Comparison, ConcreteRelatedModel, Fo...
41aef44dde35fb5d0546a49d8b69437768e2ae249c34caa6141510087247a514
import os from io import StringIO from unittest import mock from admin_scripts.tests import AdminScriptTestCase from django.apps import apps from django.core import management from django.core.management import BaseCommand, CommandError, find_commands from django.core.management.utils import ( find_command, get_r...
d97c150eef1540ed4b82aa49b742c041bfd14af090d7fc650194778aa149383d
from django.urls import path urlpatterns = [ path('some/url/', lambda req:req, name='some_url'), ]
730120acd9dec4d8c1867bcab3b94a7928e5d3a55cd5b6bde336523dd56c8636
from django.urls import path def some_view(request): pass urlpatterns = [ path('some-url/', some_view, name='some-view'), ]
4a6326cbc19ac8777349858c8527677a1d4cd431db2bf5f14d005e1e74d6b407
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, override_settings from django.test.u...
ee3aa24a98e30edd7a3484ea528a139cf5aaedc4a66e7238634898c683f397b8
import sys import unittest from django.conf import settings from django.contrib.admindocs import utils, views from django.contrib.admindocs.views import get_return_data_type, simplify_regex from django.contrib.sites.models import Site from django.db import models from django.db.models import fields from django.test im...
b584b3a704215d4e6a50b0f4cd4dee755ea502ab7f0529ac9b7bea8e340b0dd9
import unittest from django.contrib.admindocs.utils import ( docutils_is_available, parse_docstring, parse_rst, trim_docstring, ) from .tests import AdminDocsSimpleTestCase @unittest.skipUnless(docutils_is_available, "no docutils installed.") class TestUtils(AdminDocsSimpleTestCase): """ This __doc__ ou...
1f7606a542ec5f786ee2e7a723b9f188f5ad32101b5d9342910c54ff5cc08154
from django.contrib.auth.models import User from django.test import ( SimpleTestCase, TestCase, modify_settings, override_settings, ) class TestDataMixin: @classmethod def setUpTestData(cls): cls.superuser = User.objects.create_superuser(username='super', password='secret', email='super@example.c...
16a19b8f724e108cc91e575328e91b86411fcf7e29f7db85e57d9be79507a610
from django.contrib import admin from django.urls import include, path from . import views backend_urls = ([ path('something/', views.XViewClass.as_view(), name='something'), ], 'backend') urlpatterns = [ path('admin/doc/', include('django.contrib.admindocs.urls')), path('admin/', admin.site.urls), p...
a7c6212975996c0a3d59b7fab873e1a310420054e8ef720b5ce45a5f28a1d665
from django.contrib import admin from django.urls import include, path from . import views ns_patterns = ([ path('xview/func/', views.xview_dec(views.xview), name='func'), ], 'test') urlpatterns = [ path('admin/', admin.site.urls), path('admindocs/', include('django.contrib.admindocs.urls')), path(''...
bfe6698007e0d3976c0a395cbc40ce2d277268791492bd0745c3fc89b8b5814a
from django.conf import settings from django.core.exceptions import MiddlewareNotUsed from django.test import RequestFactory, SimpleTestCase, override_settings from . import middleware as mw @override_settings(ROOT_URLCONF='middleware_exceptions.urls') class MiddlewareTests(SimpleTestCase): def tearDown(self): ...
12c19c8eed6b399be04767c4103c14d568912ed0b5206b81fc8242719614232e
from django.urls import path from . import views urlpatterns = [ path('middleware_exceptions/view/', views.normal_view), path('middleware_exceptions/error/', views.server_error), path('middleware_exceptions/permission_denied/', views.permission_denied), path('middleware_exceptions/exception_in_render/...
b3e68f2809f08276ab2a8cef6da837a224ad6876cc96b095847f812bdd946ce7
from django.http import Http404, HttpResponse from django.template import engines from django.template.response import TemplateResponse log = [] class BaseMiddleware: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): return self.get_response(requ...
8375ab981bd9055808596b0ea2cbfdc5245c8d8b4730447075e7b40d84c57d88
from django.core.exceptions import PermissionDenied from django.http import HttpResponse from django.template import engines from django.template.response import TemplateResponse def normal_view(request): return HttpResponse('OK') def template_response(request): template = engines['django'].from_string('tem...
e08e5492e313a3ad6303051401c5d6734a55a2bf6708f52dc7d08dad6a27c41b
from django.db.models import Q, Sum from django.db.models.deletion import ProtectedError from django.db.utils import IntegrityError from django.forms.models import modelform_factory from django.test import TestCase, skipIfDBFeature from .models import ( A, Address, B, Board, C, Cafe, CharLink, Company, Contact, Co...
9404977e649f4c0864f2131a506c6443ca0e8df80d5d317ee5da0b26df0baaa2
from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models.deletion import ProtectedError __all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address', 'CharLink', '...
95fe283d37af9850ddb65b57cc3d60033d831ba9b5180e9703403e993ef177ce
""" Many-to-many and many-to-one relationships to the same table Make sure to set ``related_name`` if you use relationships to the same table. """ from django.db import models class User(models.Model): username = models.CharField(max_length=20) class Issue(models.Model): num = models.IntegerField() cc ...
65fdc657daf14c4882b1915bc5a8b488d56d2c35677442a92222b8d01ee752fb
import errno import gzip import os import struct import tempfile import unittest from io import BytesIO, StringIO, TextIOWrapper from unittest import mock from django.core.files import File from django.core.files.base import ContentFile from django.core.files.move import file_move_safe from django.core.files.temp impo...
a402190209b7e4bfa93b3c2412a3e0f61462f6ff9cf63ed0c9c5e4b7fc5d8076
import decimal import enum import json import unittest import uuid from django import forms from django.core import checks, exceptions, serializers, validators from django.core.exceptions import FieldError from django.core.management import call_command from django.db import IntegrityError, connection, models from dja...
500ef02bd4e531bf18b4794a6ac99d7089afb8e939bbbd34dd059eec14615641
from django.db import connection from . import PostgreSQLTestCase try: from django.contrib.postgres.signals import ( get_citext_oids, get_hstore_oids, register_type_handlers, ) except ImportError: pass # pyscogp2 isn't installed. class OIDTests(PostgreSQLTestCase): def assertOIDs(self, oid...
f5d1d99981ea7768763ddd625080817cf7c56963975efc7c14c682077e5f4970
import json from django.db.models import CharField from django.db.models.expressions import F, OuterRef, Subquery, Value from django.db.models.functions import Cast, Concat, Substr from django.test.utils import Approximate from . import PostgreSQLTestCase from .models import AggregateTestModel, StatTestModel try: ...
444bd6b6c3114989bdb84c03f740b68e30bf28729bdaad459a4c9fe0a5a3ef15
""" Test PostgreSQL full text search. These tests use dialogue from the 1975 film Monty Python and the Holy Grail. All text copyright Python (Monty) Pictures. Thanks to sacred-texts.com for the transcript. """ from django.contrib.postgres.search import ( SearchQuery, SearchRank, SearchVector, ) from django.db impo...
31bad64f2dd949ef447fe7670e30acb6016132a8a4a564e683f4f12c7e8a4abf
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.test import ignore_warnings, override_settings from django.utils import timezone from django.utils.deprecati...
748a09d862b2dc6de17894c9397fbc77fd7e35937e03eeded3248d380d6c3800
import unittest from forms_tests.widget_tests.base import WidgetTest from django.db import connection from django.test import SimpleTestCase, TestCase, modify_settings @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific tests") class PostgreSQLSimpleTestCase(SimpleTestCase): pass @uni...
6a6792b437402eb22670b88f35aea2132a17e6c58b972cc19b63435a1047bf46
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...
e1ab968ab680aa68246586cba870a6fcb8c25225ef601da5e8b83ba964a0b42b
from django.db import connection from django.test import modify_settings from . import PostgreSQLTestCase from .models import CharFieldModel, TextFieldModel @modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}) class UnaccentTest(PostgreSQLTestCase): Model = CharFieldModel @classmethod ...
41262664b0fc7f94dbfe4ee8dcdb20993fe4b8cc8e46a50f86fdbbea36a24cf5
""" Indirection layer for PostgreSQL-specific fields, so the tests don't fail when run with a backend other than PostgreSQL. """ import enum from django.db import models try: from django.contrib.postgres.fields import ( ArrayField, BigIntegerRangeField, CICharField, CIEmailField, CITextField, Date...
9355c8959726b4aa9ee90ce78904bf3314b0525ceca0dff1a9357a226e08aefe
from unittest import mock from django.contrib.postgres.indexes import ( BrinIndex, BTreeIndex, GinIndex, GistIndex, HashIndex, SpGistIndex, ) from django.db import connection from django.db.models import CharField from django.db.models.functions import Length from django.db.models.query_utils import Q from django....
a2403cc579b398fe6c393a694d3d8fc983cdc4cb4862b20870f040426063c7f5
SECRET_KEY = 'abcdefg' INSTALLED_APPS = [ 'django.contrib.postgres', ]
e430bf608d1aff3cfa10e33dcd8bef2e1c7f4d0c960a914775f480b04743c253
import datetime import operator import uuid from decimal import Decimal from django.core import checks, exceptions, serializers from django.core.serializers.json import DjangoJSONEncoder from django.db.models import Count, Q from django.forms import CharField, Form, widgets from django.test.utils import isolate_apps f...
7402c52de88a11fee1f831d061ead4ecac9df154314fa713076e1b78368e4ae9
from io import StringIO from django.core.management import call_command from django.test.utils import modify_settings from . import PostgreSQLTestCase @modify_settings(INSTALLED_APPS={'append': 'django.contrib.postgres'}) class InspectDBTests(PostgreSQLTestCase): def assertFieldsInModel(self, model, field_outpu...
87a2a0b56ad5f703dcd4c9d87dede1b8981c64bd53d18f3a6741017dc459ddb8
from django.db.backends.signals import connection_created from django.db.migrations.writer import MigrationWriter from django.test.utils import modify_settings from . import PostgreSQLTestCase try: from psycopg2.extras import ( DateRange, DateTimeRange, DateTimeTZRange, NumericRange, ) from django...
1beabe1570134f4ee1576d36b57feebb5d70db13b513f8afa56d9d20f60a1a26
import os import subprocess import sys from . import PostgreSQLSimpleTestCase class PostgresIntegrationTests(PostgreSQLSimpleTestCase): def test_check(self): test_environ = os.environ.copy() if 'DJANGO_SETTINGS_MODULE' in test_environ: del test_environ['DJANGO_SETTINGS_MODULE'] ...
4167f81a8e4c773e2e1311664ea94a07722fdb44fccf3f3dd43baef8d333f3b6
import json from django.core import checks, exceptions, serializers from django.forms import Form from django.test.utils import isolate_apps from . import PostgreSQLSimpleTestCase, PostgreSQLTestCase from .models import HStoreModel, PostgreSQLModel try: from django.contrib.postgres import forms from django.c...
0493384a073d9a0969375897c27d125241f78e37d13589680dcd2d6ac81c9018
from datetime import date from . import PostgreSQLTestCase from .models import ( HStoreModel, IntegerArrayModel, JSONModel, NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel, RangesModel, ) try: from psycopg2.extras import NumericRange, DateRange except ImportError: pass # psyc...
31cdfab8f3cdf3c9a6da54bb4c2e8bcd464ce639257d2a08f871e893f6b13d5a
from django.db import connection, transaction from django.db.models import Q from django.db.models.constraints import CheckConstraint from django.db.utils import IntegrityError from . import PostgreSQLTestCase from .models import RangesModel try: from psycopg2.extras import NumericRange except ImportError: pa...
9d560da6622762e1cdf000cb7a287d723b147bb804a6c065a2128989f9376ceb
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...
4f184e0e11510ea000f7ea9d2589581cea147d5b22efdd3a8794ced40267f1b2
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...
a475e93f692e743a19db9c935efe9a262a49bea3d7ff913d5882d1e69d0ce90e
from django.urls import path from . import feeds urlpatterns = [ path('syndication/rss2/', feeds.TestRss2Feed()), path( 'syndication/rss2/guid_ispermalink_true/', feeds.TestRss2FeedWithGuidIsPermaLinkTrue()), path( 'syndication/rss2/guid_ispermalink_false/', feeds.TestRss2F...
9ca6d8898f086f86572f2f1644598935afb08152fa8b4e59c942cda45770c859
import datetime from decimal import Decimal from django.core.exceptions import FieldDoesNotExist, FieldError from django.db.models import ( BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, Func, IntegerField, NullBooleanField, OuterRef, Q, Subquery, Sum, Value, ) from django.db.models.expre...
bb2139591079c93fd289341677cd4fbe855761ed81b6a2270708df12c8e3f852
import time import traceback from datetime import date, datetime, timedelta from threading import Thread from django.core.exceptions import FieldError from django.db import DatabaseError, IntegrityError, connection from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature from django.utils.functional ...
b0b49f44058475d187e3580ab010d8ed8b40c019708fe8cecb2b44f5e2b576a5
from django.db import models class Person(models.Model): first_name = models.CharField(max_length=100, unique=True) last_name = models.CharField(max_length=100) birthday = models.DateField() defaults = models.TextField() def __str__(self): return '%s %s' % (self.first_name, self.last_name...
9bfd89c28a359aea8e3eaddab98c99be8e80b9774aae7ad8e79ecbc5bd102460
import os import re import types from datetime import datetime, timedelta from decimal import Decimal from unittest import TestCase from django.core.exceptions import ValidationError from django.core.files.base import ContentFile from django.core.validators import ( BaseValidator, DecimalValidator, EmailValidator,...
dfec81493b46b0933ae021dd0d61b483a2baae3d037594dfff8797c7fe3c7d95
import re from io import StringIO from unittest import mock, skipUnless from django.core.management import call_command from django.db import connection from django.db.backends.base.introspection import TableInfo from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature from .models import PeopleMore...
984130d74aec6053cc7f2cfe552508878055dca87203ccc2aacdd000c2e540f8
from django.urls import path from . import views urlpatterns = [ path('render/', views.render_view), path('render/multiple_templates/', views.render_view_with_multiple_templates), path('render/content_type/', views.render_view_with_content_type), path('render/status/', views.render_view_with_status), ...
43b4efef975ddc3c615715ed13b590ab3a9e6147b156fd274c9f1d251a7fe435
from django.shortcuts import render def render_view(request): return render(request, 'shortcuts/render_test.html', { 'foo': 'FOO', 'bar': 'BAR', }) def render_view_with_multiple_templates(request): return render(request, [ 'shortcuts/no_such_template.html', 'shortcuts/ren...
75fc677bc3be061631abfcca8d1385594d5a5471fe6e570b3c3d5cc11fd39609
from django.db import IntegrityError, connection, transaction from django.test import TestCase from .models import ( Bar, Director, Favorites, HiddenPointer, ManualPrimaryKey, MultiModel, Place, Pointer, RelatedModel, Restaurant, School, Target, ToFieldPointer, UndergroundBar, Waiter, ) class OneToOneTes...