repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/custom_methods/models.py
tests/custom_methods/models.py
""" Giving models custom methods Any method you add to a model will be available to instances. """ import datetime from django.db import models class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() def __str__(self): return self.headline de...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/custom_methods/__init__.py
tests/custom_methods/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/custom_methods/tests.py
tests/custom_methods/tests.py
from datetime import date from django.test import TestCase from .models import Article class MethodsTests(TestCase): def test_custom_methods(self): a = Article.objects.create( headline="Parrot programs in Python", pub_date=date(2005, 7, 27) ) b = Article.objects.create( ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/client.py
tests/auth_tests/client.py
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[1] class PasswordResetConfirmCl...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_checks.py
tests/auth_tests/test_checks.py
from django.contrib.auth.checks import ( check_middleware, check_models_permissions, check_user_model, ) from django.contrib.auth.middleware import ( AuthenticationMiddleware, LoginRequiredMiddleware, ) from django.contrib.auth.models import AbstractBaseUser from django.contrib.sessions.middleware i...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/urls_admin.py
tests/auth_tests/urls_admin.py
""" 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. ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_context_processors.py
tests/auth_tests/test_context_processors.py
from django.contrib.auth import authenticate from django.contrib.auth.context_processors import PermLookupDict, PermWrapper from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType from django.db.models import Q from django.test import SimpleTestCase, TestCase, ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_decorators.py
tests/auth_tests/test_decorators.py
from asgiref.sync import iscoroutinefunction from django.conf import settings from django.contrib.auth import models from django.contrib.auth.decorators import ( login_not_required, login_required, permission_required, user_passes_test, ) from django.core.exceptions import PermissionDenied from django....
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_login.py
tests/auth_tests/test_login.py
from django.contrib import auth from django.contrib.auth.models import User from django.http import HttpRequest from django.test import TestCase class TestLogin(TestCase): @classmethod def setUpTestData(cls): cls.user = User.objects.create_user(username="testuser", password="password") def setUp(...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_forms.py
tests/auth_tests/test_forms.py
import datetime import re import sys import urllib.parse from unittest import mock from django import forms from django.contrib.auth.forms import ( AdminPasswordChangeForm, AdminUserCreationForm, AuthenticationForm, BaseUserCreationForm, PasswordChangeForm, PasswordResetForm, ReadOnlyPasswo...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_views.py
tests/auth_tests/test_views.py
import datetime import itertools import re from importlib import import_module from unittest import mock from urllib.parse import quote, urljoin 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, REDIRECT_F...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_templatetags.py
tests/auth_tests/test_templatetags.py
from django.contrib.auth.hashers import make_password from django.contrib.auth.templatetags.auth import render_password_as_hash from django.test import SimpleTestCase, override_settings class RenderPasswordAsHashTests(SimpleTestCase): @override_settings( PASSWORD_HASHERS=["django.contrib.auth.hashers.PBKD...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_remote_user.py
tests/auth_tests/test_remote_user.py
from datetime import UTC, datetime from django.conf import settings from django.contrib.auth import aauthenticate, 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.c...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_migrations.py
tests/auth_tests/test_migrations.py
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...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_admin_multidb.py
tests/auth_tests/test_admin_multidb.py
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...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_management.py
tests/auth_tests/test_management.py
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.conf import settings from django.contrib.auth import get_permission_codename, management from django.contrib.auth.management import ( RenamePermis...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_models.py
tests/auth_tests/test_models.py
from unittest import mock from django.conf.global_settings import PASSWORD_HASHERS from django.contrib.auth import get_user_model from django.contrib.auth.backends import ModelBackend from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.hashers import get_hasher from django.contrib.auth....
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_tokens.py
tests/auth_tests/test_tokens.py
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.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.test.utils import override_settin...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_middleware.py
tests/auth_tests/test_middleware.py
from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME, alogin, alogout from django.contrib.auth.middleware import ( AuthenticationMiddleware, LoginRequiredMiddleware, ) from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured from django....
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/settings.py
tests/auth_tests/settings.py
import os AUTH_MIDDLEWARE = [ "django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", ] AUTH_TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [os.path.join(os.path.dirname(__file__), "templates"...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/__init__.py
tests/auth_tests/__init__.py
# The password for the fixture data users is 'password'
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_mixins.py
tests/auth_tests/test_mixins.py
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 Http...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_hashers.py
tests/auth_tests/test_hashers.py
from contextlib import contextmanager 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, Argon2PasswordHasher, BasePasswordHasher, BCryptPasswordHasher, ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_signals.py
tests/auth_tests/test_signals.py
from django.apps import apps from django.contrib.auth import authenticate, signals from django.contrib.auth.models import User from django.core.exceptions import FieldDoesNotExist from django.test import TestCase, override_settings from django.test.client import RequestFactory from .models import MinimalUser, UserWith...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_auth_backends.py
tests/auth_tests/test_auth_backends.py
import sys from datetime import date from unittest import mock from unittest.mock import patch from asgiref.sync import sync_to_async from django.contrib.auth import ( BACKEND_SESSION_KEY, SESSION_KEY, _clean_credentials, aauthenticate, authenticate, get_user, signals, ) from django.contri...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_templates.py
tests/auth_tests/test_templates.py
from datetime import date 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, PasswordRe...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/urls_custom_user_admin.py
tests/auth_tests/urls_custom_user_admin.py
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, obj, message): # LogEntry.user colu...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_basic.py
tests/auth_tests/test_basic.py
from django.conf import settings from django.contrib.auth import aget_user, 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 TestCas...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_handlers.py
tests/auth_tests/test_handlers.py
from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user from django.contrib.auth.models import Group, User from django.test import TransactionTestCase, override_settings from .models import CustomUser # This must be a TransactionTestCase because the WSGI auth handler performs # its own trans...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/urls.py
tests/auth_tests/urls.py
from django.contrib import admin from django.contrib.auth import views from django.contrib.auth.decorators import ( login_not_required, login_required, permission_required, ) from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.urls import urlpatterns as auth_urlpatterns from dj...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/backend_alias.py
tests/auth_tests/backend_alias.py
# For testing that auth backends can be referenced using a convenience import from .test_auth_backends import ImportedModelBackend __all__ = ["ImportedModelBackend"]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/test_validators.py
tests/auth_tests/test_validators.py
import os from unittest import mock 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_p...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/no_password.py
tests/auth_tests/models/no_password.py
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.db import models class UserManager(BaseUserManager): def _create_user(self, username, **extra_fields): user = self.model(username=username, **extra_fields) user.save(using=self._db) return user def...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_last_login_attr.py
tests/auth_tests/models/with_last_login_attr.py
from django.contrib.auth.base_user import AbstractBaseUser class UserWithDisabledLastLoginField(AbstractBaseUser): last_login = None
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/custom_user.py
tests/auth_tests/models/custom_user.py
from django.contrib.auth.models import ( AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission, PermissionsMixin, UserManager, ) from django.db import models # The custom user uses email as the unique identifier, and requires # that every user provide a date of birth. This let...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_custom_email_field.py
tests/auth_tests/models/with_custom_email_field.py
from django.contrib.auth.base_user import AbstractBaseUser from django.contrib.auth.models import BaseUserManager from django.db import models class CustomEmailFieldUserManager(BaseUserManager): def create_user(self, username, password, email): user = self.model(username=username) user.set_passwor...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_unique_constraint.py
tests/auth_tests/models/with_unique_constraint.py
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models class CustomUserWithUniqueConstraintManager(BaseUserManager): def create_superuser(self, username, password): user = self.model(username=username) user.set_password(password) user.save(usi...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/minimal.py
tests/auth_tests/models/minimal.py
from django.db import models class MinimalUser(models.Model): REQUIRED_FIELDS = () USERNAME_FIELD = "id"
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_foreign_key.py
tests/auth_tests/models/with_foreign_key.py
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, Group from django.db import models class Email(models.Model): email = models.EmailField(verbose_name="email address", max_length=255, unique=True) class CustomUserWithFKManager(BaseUserManager): def create_superuser(self, username, em...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_many_to_many.py
tests/auth_tests/models/with_many_to_many.py
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models class Organization(models.Model): name = models.CharField(max_length=255) class CustomUserWithM2MManager(BaseUserManager): def create_superuser(self, username, orgs, password): user = self.model(use...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/custom_permissions.py
tests/auth_tests/models/custom_permissions.py
""" The CustomPermissionsUser users email as the identifier, but uses the normal Django permissions model. This allows us to check that the PermissionsMixin includes everything that is needed to interact with the ModelBackend. """ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.db...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/with_integer_username.py
tests/auth_tests/models/with_integer_username.py
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models class IntegerUsernameUserManager(BaseUserManager): def create_user(self, username, password): user = self.model(username=username) user.set_password(password) user.save(using=self._db) ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/__init__.py
tests/auth_tests/models/__init__.py
from .custom_permissions import CustomPermissionsUser from .custom_user import ( CustomUser, CustomUserCompositePrimaryKey, CustomUserWithoutIsActiveField, ExtensionUser, ) from .invalid_models import CustomUserNonUniqueUsername from .is_active import IsActiveTestUser1 from .minimal import MinimalUser f...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/uuid_pk.py
tests/auth_tests/models/uuid_pk.py
import uuid from django.contrib.auth.models import AbstractUser from django.db import models from .custom_user import RemoveGroupsAndPermissions with RemoveGroupsAndPermissions(): class UUIDUser(AbstractUser): """A user with a UUID as primary key""" id = models.UUIDField(default=uuid.uuid4, pri...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/invalid_models.py
tests/auth_tests/models/invalid_models.py
from django.contrib.auth.models import AbstractBaseUser, UserManager from django.db import models class CustomUserNonUniqueUsername(AbstractBaseUser): """ A user with a non-unique username. This model is not invalid if it is used with a custom authentication backend which supports non-unique username...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/is_active.py
tests/auth_tests/models/is_active.py
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager from django.db import models class IsActiveTestUser1(AbstractBaseUser): """ This test user class and derivatives test the default is_active behavior """ username = models.CharField(max_length=30, unique=True) custom_objects...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/models/proxy.py
tests/auth_tests/models/proxy.py
from django.contrib.auth.models import User from django.db import models class Concrete(models.Model): pass class Proxy(Concrete): class Meta: proxy = True permissions = (("display_proxys", "May display proxys information"),) class UserProxy(User): class Meta: proxy = True ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/operations_migrations/0001_initial.py
tests/auth_tests/operations_migrations/0001_initial.py
from django.db import migrations, models class Migration(migrations.Migration): initial = True operations = [ migrations.CreateModel( name="OldModel", fields=[ ("id", models.AutoField(primary_key=True)), ], ), ]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/operations_migrations/__init__.py
tests/auth_tests/operations_migrations/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/auth_tests/operations_migrations/0002_rename_oldmodel_to_newmodel.py
tests/auth_tests/operations_migrations/0002_rename_oldmodel_to_newmodel.py
from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("auth_tests", "0001_initial"), ] operations = [ migrations.RenameModel( old_name="OldModel", new_name="NewModel", ), ]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/syndication_tests/models.py
tests/syndication_tests/models.py
from django.db import models class Entry(models.Model): title = models.CharField(max_length=200) updated = models.DateTimeField() published = models.DateTimeField() class Meta: ordering = ("updated",) def __str__(self): return self.title def get_absolute_url(self): r...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/syndication_tests/__init__.py
tests/syndication_tests/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/syndication_tests/tests.py
tests/syndication_tests/tests.py
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.templatetags.static import static from django.test import TestCase, override_settings from django.test.utils import r...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/syndication_tests/feeds.py
tests/syndication_tests/feeds.py
from functools import wraps from django.contrib.syndication import views from django.utils import feedgenerator from django.utils.timezone import get_fixed_timezone from .models import Article, Entry def wraps_decorator(f): @wraps(f) def wrapper(*args, **kwargs): value = f(*args, **kwargs) r...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/syndication_tests/urls.py
tests/syndication_tests/urls.py
from django.urls import path from . import feeds urlpatterns = [ path("syndication/rss2/", feeds.TestRss2Feed()), path( "syndication/rss2/with-callable-object/", feeds.TestRss2FeedWithCallableObject() ), path( "syndication/rss2/with-decorated-methods/", feeds.TestRss2FeedWithDe...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/admin_ordering/models.py
tests/admin_ordering/models.py
from django.contrib import admin from django.db import models class Band(models.Model): name = models.CharField(max_length=100) bio = models.TextField() rank = models.IntegerField() class Meta: ordering = ("name",) class Song(models.Model): band = models.ForeignKey(Band, models.CASCADE)...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/admin_ordering/__init__.py
tests/admin_ordering/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/admin_ordering/tests.py
tests/admin_ordering/tests.py
from django.contrib import admin from django.contrib.admin.options import ModelAdmin from django.contrib.auth.models import User from django.db.models import F from django.test import RequestFactory, TestCase from .models import ( Band, DynOrderingBandAdmin, Song, SongInlineDefaultOrdering, SongInl...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/project_template/views.py
tests/project_template/views.py
from django.http import HttpResponse def empty_view(request, *args, **kwargs): return HttpResponse()
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/project_template/__init__.py
tests/project_template/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/project_template/test_settings.py
tests/project_template/test_settings.py
import os import shutil import tempfile from django import conf from django.test import SimpleTestCase from django.test.utils import extend_sys_path class TestStartProjectSettings(SimpleTestCase): def setUp(self): self.temp_dir = tempfile.TemporaryDirectory() self.addCleanup(self.temp_dir.cleanup...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/project_template/urls.py
tests/project_template/urls.py
from django.urls import path from . import views urlpatterns = [ path("empty/", views.empty_view), ]
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/test_default_pk.py
tests/model_options/test_default_pk.py
from django.core.exceptions import ImproperlyConfigured from django.db import models from django.test import SimpleTestCase, override_settings from django.test.utils import isolate_apps class MyBigAutoField(models.BigAutoField): pass @isolate_apps("model_options") class TestDefaultPK(SimpleTestCase): def te...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/__init__.py
tests/model_options/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/apps.py
tests/model_options/apps.py
from django.apps import AppConfig class ModelDefaultPKConfig(AppConfig): name = "model_options" class ModelPKConfig(AppConfig): name = "model_options" default_auto_field = "django.db.models.SmallAutoField" class ModelPKNonAutoConfig(AppConfig): name = "model_options" default_auto_field = "djan...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/test_default_related_name.py
tests/model_options/test_default_related_name.py
from django.core.exceptions import FieldError from django.test import TestCase from .models.default_related_name import Author, Book, Editor class DefaultRelatedNameTests(TestCase): @classmethod def setUpTestData(cls): cls.author = Author.objects.create(first_name="Dave", last_name="Loper") c...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/test_tablespaces.py
tests/model_options/test_tablespaces.py
from django.apps import apps from django.conf import settings from django.db import connection from django.test import TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature from .models.tablespaces import ( Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef, ) def sql_for_ta...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/models/tablespaces.py
tests/model_options/models/tablespaces.py
from django.db import models # Since the test database doesn't have tablespaces, it's impossible for Django # to create the tables for models where db_tablespace is set. To avoid this # problem, we mark the models as unmanaged, and temporarily revert them to # managed during each test. We also set them to use the same...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/models/default_related_name.py
tests/model_options/models/default_related_name.py
from django.db import models class Author(models.Model): first_name = models.CharField(max_length=128) last_name = models.CharField(max_length=128) class Editor(models.Model): name = models.CharField(max_length=128) bestselling_author = models.ForeignKey(Author, models.CASCADE) class Book(models.M...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/model_options/models/__init__.py
tests/model_options/models/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/signals/models.py
tests/signals/models.py
""" Testing signals before/after saving and deleting. """ from django.db import models class Person(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) def __str__(self): return "%s %s" % (self.first_name, self.last_name) class Car(models.Mod...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/signals/__init__.py
tests/signals/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/signals/tests.py
tests/signals/tests.py
import contextvars from unittest import mock from asgiref.sync import markcoroutinefunction from django import dispatch from django.apps.registry import Apps from django.db import models from django.db.models import signals from django.dispatch import receiver from django.test import SimpleTestCase, TestCase from dja...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/filtered_relation/models.py
tests/filtered_relation/models.py
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType from django.db import models class Author(models.Model): name = models.CharField(max_length=50, unique=True) favorite_books = models.ManyToManyField( "Book", ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/filtered_relation/__init__.py
tests/filtered_relation/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/filtered_relation/tests.py
tests/filtered_relation/tests.py
from datetime import date from decimal import Decimal from unittest import mock from django.db import connection, transaction from django.db.models import ( BooleanField, Case, Count, DecimalField, ExpressionWrapper, F, FilteredRelation, Q, Sum, Value, When, ) from django.db...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
true
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_through_regress/models.py
tests/m2m_through_regress/models.py
from django.contrib.auth.models import User from django.db import models # Forward declared intermediate model class Membership(models.Model): person = models.ForeignKey("Person", models.CASCADE) group = models.ForeignKey("Group", models.CASCADE) price = models.IntegerField(default=100) # using custom i...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_through_regress/test_multitable.py
tests/m2m_through_regress/test_multitable.py
from django.test import TestCase from .models import ( CompetingTeam, Event, Group, IndividualCompetitor, Membership, Person, ) class MultiTableTests(TestCase): @classmethod def setUpTestData(cls): cls.alice = Person.objects.create(name="Alice") cls.bob = Person.object...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_through_regress/__init__.py
tests/m2m_through_regress/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_through_regress/tests.py
tests/m2m_through_regress/tests.py
from io import StringIO from django.contrib.auth.models import User from django.core import management from django.test import TestCase from .models import Car, CarDriver, Driver, Group, Membership, Person, UserMembership class M2MThroughTestCase(TestCase): @classmethod def setUpTestData(cls): cls.b...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_regress/models.py
tests/m2m_regress/models.py
from django.contrib.auth import models as auth from django.db import models # No related name is needed here, since symmetrical relations are not # explicitly reversible. class SelfRefer(models.Model): name = models.CharField(max_length=10) references = models.ManyToManyField("self") related = models.Many...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_regress/__init__.py
tests/m2m_regress/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_regress/tests.py
tests/m2m_regress/tests.py
from django.core.exceptions import FieldError from django.test import TestCase from .models import ( Entry, Line, Post, RegressionModelSplit, SelfRefer, SelfReferChild, SelfReferChildSibling, Tag, TagCollection, Worksheet, ) class M2MRegressionTests(TestCase): def test_mul...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/test_exception.py
tests/handlers/test_exception.py
from django.core.handlers.wsgi import WSGIHandler from django.test import SimpleTestCase, override_settings from django.test.client import ( BOUNDARY, MULTIPART_CONTENT, FakePayload, encode_multipart, ) class ExceptionHandlerTests(SimpleTestCase): def get_suspicious_environ(self): payload ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/views.py
tests/handlers/views.py
import asyncio from http import HTTPStatus from django.core.exceptions import BadRequest, SuspiciousOperation from django.db import connection, transaction from django.http import HttpResponse, StreamingHttpResponse from django.views.decorators.csrf import csrf_exempt def regular(request): return HttpResponse(b"...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/tests_custom_error_handlers.py
tests/handlers/tests_custom_error_handlers.py
from django.core.exceptions import PermissionDenied from django.template.response import TemplateResponse from django.test import SimpleTestCase, modify_settings, override_settings from django.urls import path class MiddlewareAccessingContent: def __init__(self, get_response): self.get_response = get_resp...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/__init__.py
tests/handlers/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/tests.py
tests/handlers/tests.py
from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import WSGIHandler, WSGIRequest, get_script_name from django.core.signals import request_finished, request_started from django.db import close_old_connections, connection from django.test import ( AsyncRequestFactory, Request...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/handlers/urls.py
tests/handlers/urls.py
from django.urls import path from . import views urlpatterns = [ path("regular/", views.regular), path("async_regular/", views.async_regular), path("no_response_fbv/", views.no_response), path("no_response_cbv/", views.NoResponse()), path("streaming/", views.streaming), path("async_streaming/"...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/update/models.py
tests/update/models.py
""" Tests for the update() queryset method that allows in-place, multi-object updates. """ from django.db import models class DataPoint(models.Model): name = models.CharField(max_length=20) value = models.CharField(max_length=20) another_value = models.CharField(max_length=20, blank=True) is_active =...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/update/__init__.py
tests/update/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/update/tests.py
tests/update/tests.py
import unittest from django.core.exceptions import FieldError from django.db import IntegrityError, connection, transaction from django.db.models import Case, CharField, Count, F, IntegerField, Max, When from django.db.models.functions import Abs, Concat, Lower from django.test import TestCase from django.test.utils i...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_recursive/models.py
tests/m2m_recursive/models.py
""" Many-to-many relationships between the same two tables In this example, a ``Person`` can have many friends, who are also ``Person`` objects. Friendship is a symmetrical relationship - if I am your friend, you are my friend. Here, ``friends`` is an example of a symmetrical ``ManyToManyField``. A ``Person`` can als...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_recursive/__init__.py
tests/m2m_recursive/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/m2m_recursive/tests.py
tests/m2m_recursive/tests.py
import datetime from django.test import TestCase from .models import Person class RecursiveM2MTests(TestCase): @classmethod def setUpTestData(cls): cls.a, cls.b, cls.c, cls.d = [ Person.objects.create(name=name) for name in ["Anne", "Bill", "Chuck", "David"] ] ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_one_null/models.py
tests/many_to_one_null/models.py
""" Many-to-one relationships that can be null To define a many-to-one relationship that can have a null foreign key, use ``ForeignKey()`` with ``null=True`` . """ from django.db import models class Reporter(models.Model): name = models.CharField(max_length=30) class Article(models.Model): headline = mode...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_one_null/__init__.py
tests/many_to_one_null/__init__.py
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/many_to_one_null/tests.py
tests/many_to_one_null/tests.py
from django.test import TestCase from .models import Article, Car, Driver, Reporter class ManyToOneNullTests(TestCase): @classmethod def setUpTestData(cls): # Create a Reporter. cls.r = Reporter(name="John Smith") cls.r.save() # Create an Article. cls.a = Article(headl...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/resolve_url/views.py
tests/resolve_url/views.py
from django.http import HttpResponse from django.views import View def some_view(request): return HttpResponse("ok") def params_view(request, slug): return HttpResponse(f"Params: {slug}") class SomeView(View): def get(self, request): return HttpResponse("ok") class ParamsView(View): def ...
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false
django/django
https://github.com/django/django/blob/3201a895cba335000827b28768a7b7105c81b415/tests/resolve_url/models.py
tests/resolve_url/models.py
""" Regression tests for the resolve_url function. """ from django.db import models class UnimportantThing(models.Model): importance = models.IntegerField() def get_absolute_url(self): return "/importance/%d/" % self.importance
python
BSD-3-Clause
3201a895cba335000827b28768a7b7105c81b415
2026-01-04T14:38:15.489092Z
false