hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
34040ce91512b5b457465e7893f6dd045319a535e35ba2f5c0aa2c41b4d75b33 | import mimetypes
from email import (
charset as Charset, encoders as Encoders, generator, message_from_string,
)
from email.errors import InvalidHeaderDefect, NonASCIILocalPartDefect
from email.header import Header
from email.headerregistry import Address
from email.message import Message
from email.mime.base impor... |
befb31284c1bdea1e09c21b447929491f529307b9931fc63a3df97fb6053a7ee | from django.conf import settings
from .. import Tags, Warning, register
def add_session_cookie_message(message):
return message + (
" Using a secure-only session cookie makes it more difficult for "
"network traffic sniffers to hijack user sessions."
)
W010 = Warning(
add_session_cookie... |
26c17c52f24b9565c5db2b2cc16693d3c32a77a283b78c1e394af5faca4266df | from django.conf import settings
from .. import Tags, Warning, register
SECRET_KEY_MIN_LENGTH = 50
SECRET_KEY_MIN_UNIQUE_CHARACTERS = 5
W001 = Warning(
"You do not have 'django.middleware.security.SecurityMiddleware' "
"in your MIDDLEWARE so the SECURE_HSTS_SECONDS, "
"SECURE_CONTENT_TYPE_NOSNIFF, "
... |
087d3dade3875d011d08caa195e8f287422c1b00d09057874583b6e609594d81 | from django.conf import settings
from .. import Tags, Warning, register
W003 = Warning(
"You don't appear to be using Django's built-in "
"cross-site request forgery protection via the middleware "
"('django.middleware.csrf.CsrfViewMiddleware' is not in your "
"MIDDLEWARE). Enabling the middleware is ... |
88a9613e9385b21fc19b98d74527d05fdcd84d94dd421effd12cd90e540f37b1 | import time
from collections import OrderedDict
from importlib import import_module
from django.apps import apps
from django.core.checks import Tags, run_checks
from django.core.management.base import (
BaseCommand, CommandError, no_translations,
)
from django.core.management.sql import (
emit_post_migrate_sig... |
9f099103dadd79abc33e62296469941bbf5f7ed8eb69d2adae880d20de026a40 | from django.apps import apps
from django.core import checks
from django.core.checks.registry import registry
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = "Checks the entire Django project for potential problems."
requires_system_checks = False
def ... |
842c9cea883b2b87036d57e57fce65bac828433d1f5a23b2968e89b65a2577c5 | from django.core.management.base import AppCommand
from django.db import DEFAULT_DB_ALIAS, connections
class Command(AppCommand):
help = 'Prints the SQL statements for resetting sequences for the given app name(s).'
output_transaction = True
def add_arguments(self, parser):
super().add_arguments... |
f65272fdc18c6a37559ab2f0745a58a8308df3d1baf7161c8f004d7cea644557 | from importlib import import_module
from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
from django.core.management.sql import emit_post_migrate_signal, sql_flush
from django.db import DEFAULT_DB_ALIAS, connections
class Com... |
afc0900f28353bcd8fbbea75e7267a234d5adce3fe0728b2b8a7a3b3d02f63d1 | import warnings
from collections import OrderedDict
from django.apps import apps
from django.core import serializers
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import parse_apps_and_model_labels
from django.db import DEFAULT_DB_ALIAS, router
class ProxyModelWa... |
945f8e18e28336d05930241b41b1c18f2b31068ffc2afddf43ecd20de1079e71 | import errno
import os
import re
import socket
import sys
from datetime import datetime
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.servers.basehttp import (
WSGIServer, get_internal_wsgi_application, run,
)
from django.utils import autoreload... |
55ea3e53af4d504c85b8cfcef6d1bb1a3459dda476bd6cdc69559a84021d4bf3 | from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.db import connection
class Command(BaseCommand):
help = 'Runs a development server with data from the given fixture(s).'
requires_system_checks = False
def add_arguments(self, parser):
... |
ddab3eaf9fe47d2f25c3ddd23bbc5436cd76a7f20654ecc6e375132dd70c5f1f | from django.core.management.base import BaseCommand
def module_to_dict(module, omittable=lambda k: k.startswith('_')):
"""Convert a module namespace to a Python dictionary."""
return {k: repr(v) for k, v in module.__dict__.items() if not omittable(k)}
class Command(BaseCommand):
help = """Displays diffe... |
385fd5663c012ab878e77a010f26cddecd0569dd7c8349536cdd599fe21998e1 | from django.apps import apps
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections, migrations
from django.db.migrations.loader import AmbiguityError, MigrationLoader
from django.db.migrations.migration import SwappableTupl... |
b9a5ab4c204ca418d1a64018b38c00a2da769fba3a4b5374f4cb1eafa120ba5c | import codecs
import concurrent.futures
import glob
import os
from django.core.management.base import BaseCommand, CommandError
from django.core.management.utils import find_command, popen_wrapper
def has_bom(fn):
with open(fn, 'rb') as f:
sample = f.read(4)
return sample.startswith((codecs.BOM_UTF8,... |
98dc6a481a7e7c5dfa87724cb44b03bd8cc2cacc43039474223872898c833222 | from django.core.management.base import BaseCommand
from django.core.management.sql import sql_flush
from django.db import DEFAULT_DB_ALIAS, connections
class Command(BaseCommand):
help = (
"Returns a list of the SQL statements required to return all tables in "
"the database to the state they wer... |
aaebcdaa6d257e5defbc37cbd12d2906d5b5b5eecb19c60d52bada73894c0008 | import socket
from django.core.mail import mail_admins, mail_managers, send_mail
from django.core.management.base import BaseCommand
from django.utils import timezone
class Command(BaseCommand):
help = "Sends a test email to the email addresses specified as arguments."
missing_args_message = "You must specif... |
5aa91117f39c7fa5bbbae395dc2e18b11ca41a6ba90bcc51b5f35440ca94c306 | import functools
import glob
import gzip
import os
import sys
import warnings
import zipfile
from itertools import product
from django.apps import apps
from django.conf import settings
from django.core import serializers
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import Ba... |
aef5c0a662dd3f78018a729a38c26d4f583762b8154e51ed7aa36a162a0dbbc6 | from django.core.management.templates import TemplateCommand
class Command(TemplateCommand):
help = (
"Creates a Django app directory structure for the given app name in "
"the current directory or optionally in the given directory."
)
missing_args_message = "You must provide an applicatio... |
ca03fde59125768b601159b10d804f53201e74d4134f026e94a2e29c653166d8 | from django.core.management.templates import TemplateCommand
from ..utils import get_random_secret_key
class Command(TemplateCommand):
help = (
"Creates a Django project directory structure for the given project "
"name in the current directory or optionally in the given directory."
)
mis... |
1530939b4112c68cd056977ea8c806c6f2188c9bb59bdeaeab923028542d7e17 | import sys
from django.conf import settings
from django.core.management.base import BaseCommand
from django.test.utils import get_runner
class Command(BaseCommand):
help = 'Discover and run tests in the specified modules or the current directory.'
# DiscoverRunner runs the checks after databases are set up.... |
086fa22b8fdf60646e5dcbdd854ed1de2bdcbd6eae36660d204c7e09095cf89a | from django.conf import settings
from django.core.cache import caches
from django.core.cache.backends.db import BaseDatabaseCache
from django.core.management.base import BaseCommand, CommandError
from django.db import (
DEFAULT_DB_ALIAS, connections, models, router, transaction,
)
from django.db.utils import Databa... |
39e7b105025711402b38a5862a9052b1a034e375f552893335673f1036c98b93 | from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections
class Command(BaseCommand):
help = (
"Runs the command-line client for specified database, or the "
"default database if none is provided."
)
requires_system_checks = Fals... |
1b8a45beb626434ba520253f4cbfe5f06c9da99b57b70069b8d88ee7d1a25e53 | import fnmatch
import glob
import os
import re
import sys
from functools import total_ordering
from itertools import dropwhile
import django
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.files.temp import NamedTemporaryFile
from django.core.management.base im... |
828f733168967eb52a6d735af729d82c842ef1f2cd4355ebe35d69af7713145f | from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.loader import AmbiguityError
class Command(BaseCommand):
help = "Prints the SQL s... |
390da8bd18e0cb803f2d152d15eeaedac8949f4c6a5010fe423de8eca7b946ab | from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.loader import MigrationLoader
class Command(BaseCommand):
help = "Shows all available migrations for the current project"
def add_arguments(self, parser):
pa... |
55e8f253abce581dda78016178c085c59968c84bd36f7845314f4d10310ba875 | import keyword
import re
from collections import OrderedDict
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections
from django.db.models.constants import LOOKUP_SEP
class Command(BaseCommand):
help = "Introspects the database tables in the given dat... |
c9f86f7bfd554b4c59d38bdbc4054eb7168ed3033f483c6650d9e3469f7fd50b | import os
import sys
from itertools import takewhile
from django.apps import apps
from django.conf import settings
from django.core.management.base import (
BaseCommand, CommandError, no_translations,
)
from django.db import DEFAULT_DB_ALIAS, connections, router
from django.db.migrations import Migration
from djan... |
0513a3aef3cd0a9d640ba8c0aeb3848337728f47fa30d878a7beb4c3635d0b21 | import os
import select
import sys
import traceback
from django.core.management import BaseCommand, CommandError
from django.utils.datastructures import OrderedSet
class Command(BaseCommand):
help = (
"Runs a Python interactive interpreter. Tries to use IPython or "
"bpython, if one of them is av... |
bafe9ceacafda0dfa8e4f36a06a0d25631e3fa98425a6b6c6a678b38ad9ec508 | "File-based cache backend"
import glob
import hashlib
import os
import pickle
import random
import tempfile
import time
import zlib
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.core.files import locks
from django.core.files.move import file_move_safe
def _write_content(f, expiry... |
808d4f76ac6ccc62ffeef23a02c7e819caa2772a582dfea43e251bebf0adfb65 | "Memcached cache backend"
import pickle
import re
import time
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.utils.functional import cached_property
class BaseMemcachedCache(BaseCache):
def __init__(self, server, params, library, value_not_found_exception):
super().__... |
d4d4c391eae4a3bb8e881d70ca9d1ccf1f3818c1e0caa5cffda232d83830dd20 | "Database cache backend."
import base64
import pickle
from datetime import datetime
from django.conf import settings
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.db import DatabaseError, connections, models, router, transaction
from django.utils import timezone
from django.utils.i... |
beb3212ab000a34bdb48339fb1054c5fc3857d1389645a1e6e87e7b651693cc8 | "Base Cache class."
import time
import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils.module_loading import import_string
class InvalidCacheBackendError(ImproperlyConfigured):
pass
class CacheKeyWarning(RuntimeWarning):
pass
# Stub class to ensure not passing in a `tim... |
cc98885cb549f53b9c6fffd1a18405b9925e4af869086ecdbe92c980ea7c6df9 | "Dummy cache backend"
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
class DummyCache(BaseCache):
def __init__(self, host, *args, **kwargs):
super().__init__(*args, **kwargs)
def add(self, key, value, timeout=DEFAULT_TIMEOUT, version=None):
key = self.make_key(key, ve... |
2344699bdd161b679288637ca55000641476a50cf9a2adfce3811507da6ae39b | "Thread-safe in-memory cache backend."
import pickle
import time
from collections import OrderedDict
from threading import Lock
from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
# Global in-memory store of cache data. Keyed by name, to provide
# multiple named local memory caches.
_caches = {}
_e... |
9755c511205b93535ecb96d482309854fa120f38e86f320adc6310cb1417d509 | """
Email backend that writes messages to console instead of sending them.
"""
import sys
import threading
from django.core.mail.backends.base import BaseEmailBackend
class EmailBackend(BaseEmailBackend):
def __init__(self, *args, **kwargs):
self.stream = kwargs.pop('stream', sys.stdout)
self._lo... |
549ffd74158a038f0c5c1657554693cbd36181f4689daa40e9402354510f283f | # Mail backends shipped with Django.
|
38f45ce650ec07d19b95edb9d5fc17a74a2ad6a29e64cf53d894dc6702ffe63b | """Email backend that writes messages to a file."""
import datetime
import os
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.mail.backends.console import (
EmailBackend as ConsoleEmailBackend,
)
class EmailBackend(ConsoleEmailBackend):
def __init__(... |
7fd39e6b0d510223c79ac4dd41a91e63311a6df3ad50bcf452f95d3f80b27699 | """Base email backend class."""
class BaseEmailBackend:
"""
Base class for email backend implementations.
Subclasses must at least overwrite send_messages().
open() and close() can be called indirectly by using a backend object as a
context manager:
with backend as connection:
... |
4c4daffbdeab4a037b9d9ff709facd73bfb452d93800b077a1b470f935dfcfdd | """SMTP email backend class."""
import smtplib
import socket
import ssl
import threading
from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend
from django.core.mail.message import sanitize_address
from django.core.mail.utils import DNS_NAME
class EmailBackend(BaseEmailBackend):... |
b08eed01adcc7c6e3750701176eb6d06f1006187e22dab20177f63cda64fbbd1 | """
Dummy email backend that does nothing.
"""
from django.core.mail.backends.base import BaseEmailBackend
class EmailBackend(BaseEmailBackend):
def send_messages(self, email_messages):
return len(list(email_messages))
|
3a04caff840686c05daad0ca63a6f060d2b0d8c5ee75cd0f485e46355a92ee09 | """
Backend for test environment.
"""
from django.core import mail
from django.core.mail.backends.base import BaseEmailBackend
class EmailBackend(BaseEmailBackend):
"""
An email backend for use during test sessions.
The test connection stores email messages in a dummy outbox,
rather than sending the... |
e292fec59de734f6dccebb8566a9cbf314c7e4aac62ff0b502075f04c7d67f06 | from urllib.parse import urlencode
from urllib.request import urlopen
from django.apps import apps as django_apps
from django.conf import settings
from django.core import paginator
from django.core.exceptions import ImproperlyConfigured
from django.urls import NoReverseMatch, reverse
from django.utils import translati... |
92d63d3dc5ac9afe533a5bc4746e882fc6416c632d651a4edb88f983b0c68a55 | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class SiteMapsConfig(AppConfig):
name = 'django.contrib.sitemaps'
verbose_name = _("Site Maps")
|
28ff9c0a40f854615b77865abd62bbf6002465af3700f791813c7e7a8ba7cb83 | import datetime
from calendar import timegm
from functools import wraps
from django.contrib.sites.shortcuts import get_current_site
from django.core.paginator import EmptyPage, PageNotAnInteger
from django.http import Http404
from django.template.response import TemplateResponse
from django.urls import reverse
from dj... |
4a3b769a089af2fa92a484abb3aecddbbac05e0bea47e30fab7ed507e9e64af1 | from django.contrib.messages.api import * # NOQA
from django.contrib.messages.constants import * # NOQA
default_app_config = 'django.contrib.messages.apps.MessagesConfig'
|
c865c129f579585fc495c3db5f8c098d7aba8f3a77f6db673bbb29f0dfc8cce4 | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class MessagesConfig(AppConfig):
name = 'django.contrib.messages'
verbose_name = _("Messages")
|
b163f60cffa7f1958e4ccf812c50c6ac7fe5fafa06c2b4b10b43a013226dd45e | from django.contrib.messages import constants
from django.contrib.messages.storage import default_storage
__all__ = (
'add_message', 'get_messages',
'get_level', 'set_level',
'debug', 'info', 'success', 'warning', 'error',
'MessageFailure',
)
class MessageFailure(Exception):
pass
def add_messag... |
e8fcc0af22747baa0ec2d48032b8c022c606bbf9d622980c1b4a7c7ffaf33ab8 | from django.conf import settings
from django.contrib.messages import constants
def get_level_tags():
"""
Return the message level tags.
"""
return {
**constants.DEFAULT_TAGS,
**getattr(settings, 'MESSAGE_TAGS', {}),
}
|
d0b9e2663c59ec5c7607161d274b5caee846e2490110486c73b52b71fdf53671 | from django.contrib.messages.api import get_messages
from django.contrib.messages.constants import DEFAULT_LEVELS
def messages(request):
"""
Return a lazy 'messages' context variable as well as
'DEFAULT_MESSAGE_LEVELS'.
"""
return {
'messages': get_messages(request),
'DEFAULT_MESSA... |
599c63cef128288ee6802852169fe0f5efb3507f2be892e1bbdb05b1fb5318d0 | DEBUG = 10
INFO = 20
SUCCESS = 25
WARNING = 30
ERROR = 40
DEFAULT_TAGS = {
DEBUG: 'debug',
INFO: 'info',
SUCCESS: 'success',
WARNING: 'warning',
ERROR: 'error',
}
DEFAULT_LEVELS = {
'DEBUG': DEBUG,
'INFO': INFO,
'SUCCESS': SUCCESS,
'WARNING': WARNING,
'ERROR': ERROR,
}
|
e0bf9bce04a34f0f8a821f1683c30eaa424fca295ac725e2fe31f55293f587e5 | from django.conf import settings
from django.contrib.messages.storage import default_storage
from django.utils.deprecation import MiddlewareMixin
class MessageMiddleware(MiddlewareMixin):
"""
Middleware that handles temporary messages.
"""
def process_request(self, request):
request._messages... |
479c43d832e600ed31e841a913c4d7e5b92ee338a83a262442702d7faafe5401 | from django.contrib import messages
class SuccessMessageMixin:
"""
Add a success message on successful form submission.
"""
success_message = ''
def form_valid(self, form):
response = super().form_valid(form)
success_message = self.get_success_message(form.cleaned_data)
if... |
a18f9e07300ec297f9836db6faf947e41587a43ce9923fc35bbfd71838fbce02 | default_app_config = 'django.contrib.admindocs.apps.AdminDocsConfig'
|
ad5dda5957af808ea8f3ff56634c90eb63b9092311459ad5c1916dd60a5f2a4d | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class AdminDocsConfig(AppConfig):
name = 'django.contrib.admindocs'
verbose_name = _("Administrative Documentation")
|
d473190ea771dcea2bdc3db67238ec019dce9071570168d56b77923d85301797 | "Misc. utility functions/classes for admin documentation generator."
import re
from email.errors import HeaderParseError
from email.parser import HeaderParser
from django.urls import reverse
from django.utils.encoding import force_bytes
from django.utils.safestring import mark_safe
try:
import docutils.core
... |
cdd1da57ad3224c8ee2ea3bdc54d07fa3ee1cf53e64ac7a9116640d861fe788d | from django.contrib.admindocs import views
from django.urls import path, re_path
urlpatterns = [
path(
'',
views.BaseAdminDocsView.as_view(template_name='admin_doc/index.html'),
name='django-admindocs-docroot',
),
path(
'bookmarklets/',
views.BookmarkletsView.as_view... |
019a52dc36ea5fb8e11a5dd56b5ca51a5ec85eb452fb9c5a0620c0f022c4c93d | from django.conf import settings
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
from .utils import get_view_name
class XViewMiddleware(MiddlewareMixin):
"""
Add an X-View header to internal HEAD requests.
"""
def process_view(self, request, view_func, view_a... |
3792269479c3929c38b1d7b08169214675b4bfc2c3c4d118e8d756e6fed9b9a7 | import inspect
from importlib import import_module
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 django.contrib.admindocs.uti... |
aac59f9beb846585aededbf9fc79fbd219576e7da0c3bbdc680ad2d384604bce | from django.db.models import Index
from django.utils.functional import cached_property
__all__ = ['BrinIndex', 'GinIndex', 'GistIndex']
class PostgresIndex(Index):
@cached_property
def max_name_length(self):
# Allow an index name longer than 30 characters when the suffix is
# longer than the... |
8ed9fdfa6c0e2127390ff614a10e73ff7b0de1b10f37104e083cdb18d6a0fe67 | default_app_config = 'django.contrib.postgres.apps.PostgresConfig'
|
879462e57d1a85adbd60c31f2ccd4e2aaeebaca59e49389d1f35c585121857e4 | from django.db.models import Field, FloatField
from django.db.models.expressions import CombinedExpression, Func, Value
from django.db.models.functions import Coalesce
from django.db.models.lookups import Lookup
class SearchVectorExact(Lookup):
lookup_name = 'exact'
def process_rhs(self, qn, connection):
... |
e2b4d3c1f1a64ac2e888c0604fb3cb9b1ed139269ab35f2d919a749f6adc8f09 | from django.apps import AppConfig
from django.db import connections
from django.db.backends.signals import connection_created
from django.db.models import CharField, TextField
from django.utils.translation import gettext_lazy as _
from .lookups import SearchLookup, TrigramSimilar, Unaccent
from .signals import registe... |
47c8e6eeef4ae5d3ef75b9ac4af08ef79c7ca08ecb49ab74d42797b4f5332f97 | from django.contrib.postgres.signals import (
get_citext_oids, get_hstore_oids, register_type_handlers,
)
from django.db.migrations.operations.base import Operation
class CreateExtension(Operation):
reversible = True
def __init__(self, name):
self.name = name
def state_forwards(self, app_lab... |
cc7780c8a4793219ec206239a9bb6645dc4f9bc3adc9c1011393a608dcb29c3f | from django.db.models import DateTimeField, Func, UUIDField
class RandomUUID(Func):
template = 'GEN_RANDOM_UUID()'
output_field = UUIDField()
class TransactionNow(Func):
template = 'CURRENT_TIMESTAMP'
output_field = DateTimeField()
|
80118198060c28b901ea7c9a460c79633ff4d1b5da380e810caf64a2213efdca | from django.core.exceptions import ValidationError
from django.utils.functional import SimpleLazyObject
from django.utils.text import format_lazy
def prefix_validation_error(error, prefix, code, params):
"""
Prefix a validation error message while maintaining the existing
validation data structure.
""... |
3265249606935b5f9404c1904f134eff57ec3bb999ba01acf52728bee088c89a | import functools
import psycopg2
from psycopg2 import ProgrammingError
from psycopg2.extras import register_hstore
from django.db import connections
from django.db.backends.base.base import NO_DB_ALIAS
@functools.lru_cache()
def get_hstore_oids(connection_alias):
"""Return hstore and hstore array OIDs."""
w... |
088cceb5085a6d6239fc611153de51118540e70ce18a6773f61a465ed2a95b4f | from django.db.models import Lookup, Transform
from django.db.models.lookups import Exact
from .search import SearchVector, SearchVectorExact, SearchVectorField
class PostgresSimpleLookup(Lookup):
def as_sql(self, qn, connection):
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params... |
080fe2ca0136ab7a3cb57950f497cc631a0ee870c99370f43c87261ab6a1c1d2 | from django.core.exceptions import ValidationError
from django.core.validators import (
MaxLengthValidator, MaxValueValidator, MinLengthValidator,
MinValueValidator,
)
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _, ngettext_lazy
class ArrayMaxLengt... |
6f90ba88875b20e1dfe70bdc9b540962cb2912b1f74f25899c20d84bd363158e | default_app_config = 'django.contrib.syndication.apps.SyndicationConfig'
|
857aae147ff704be8d351d9cc4b53ebc7941259dce0a36dc97c8e4cc236f13ae | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class SyndicationConfig(AppConfig):
name = 'django.contrib.syndication'
verbose_name = _("Syndication")
|
917053e241a3581aa6615534045accc4ccaa91d3de523808afe4c6a791ef092d | from calendar import timegm
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.http import Http404, HttpResponse
from django.template import TemplateDoesNotExist, loader
from django.utils i... |
f6f753903bc7d38e37ca7d2a5f1e7d8f87573e7dcff8f7fd941f005ab4a9fc19 | default_app_config = 'django.contrib.redirects.apps.RedirectsConfig'
|
c7d7fda0619b503b27d487faccbc03a64c16dccd809e5f998fce39580d76d5f8 | from django.contrib.sites.models import Site
from django.db import models
from django.utils.translation import gettext_lazy as _
class Redirect(models.Model):
site = models.ForeignKey(Site, models.CASCADE, verbose_name=_('site'))
old_path = models.CharField(
_('redirect from'),
max_length=200,... |
3fdc29f3222f0e32527c85e95983367ed0e55612afb5eff400cf4acbf8f5248b | from django.contrib import admin
from django.contrib.redirects.models import Redirect
@admin.register(Redirect)
class RedirectAdmin(admin.ModelAdmin):
list_display = ('old_path', 'new_path')
list_filter = ('site',)
search_fields = ('old_path', 'new_path')
radio_fields = {'site': admin.VERTICAL}
|
06f4ef3772170afef210aaa1c70083892099dfaf7961736db44be638d1cdc42e | from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class RedirectsConfig(AppConfig):
name = 'django.contrib.redirects'
verbose_name = _("Redirects")
|
9097d3223f06da5a1182210992a89812b79dcede3184d01f0da4d9924f42a32a | from django.apps import apps
from django.conf import settings
from django.contrib.redirects.models import Redirect
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponseGone, HttpResponsePermanentRedirect
from django.utils... |
da2a305001ab919073697fd67f452451b774a68d34502c6d7454315e3d47232a | from functools import wraps
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
from django.shortcuts import resolve_url
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_... |
bd75027c54860f355f8f1fe4879f77759dbb5b8de82356f4a53936381759e3fe | from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
UserModel = get_user_model()
class ModelBackend:
"""
Authenticates against settings.AUTH_USER_MODEL.
"""
def authenticate(self, request, username=None, password=None, **kwargs):
if username is No... |
051ebd8f3d310ba6b5afbab232eaf8606e5ea01f7ee2c9caf93490bc95b1601d | 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... |
7a697aacacb0e2b1081f104951ca8285476f7c487af4ca27ca3926f450d33a86 | from itertools import chain
from types import MethodType
from django.apps import apps
from django.conf import settings
from django.core import checks
from .management import _get_builtin_permissions
def check_user_model(app_configs=None, **kwargs):
if app_configs is None:
cls = apps.get_model(settings.A... |
8895ca8eaec54a440f1ebb363a23f5bd5c41766f5df2444125205b02a2a31e52 | from django.contrib import auth
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
from django.db import models
from django.db.models.manager imp... |
73a27b703e5271ec968e621bc21f617bb89a2166952b6eec82b9168c69917b3b | from datetime import date
from django.conf import settings
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.http import base36_to_int, int_to_base36
class PasswordResetTokenGenerator:
"""
Strategy object used to generate and check tokens for the password
reset mechanis... |
a7a791b3822db1ef015af8664a0bc68073bd475035b609720fadb88ec0a90d97 | import base64
import binascii
import functools
import hashlib
import importlib
import warnings
from collections import OrderedDict
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.signals import setting_changed
from django.dispatch import receiver
from django.ut... |
971d5fcae26be5cfdc2c9164fe5889cc4e3d397aed4510ce23d819aae54e4a81 | from django.conf import settings
from django.contrib import admin, messages
from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.admin.utils import unquote
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.forms import (
AdminPasswordChangeForm, UserChangeForm, U... |
346772d61e32ae88029fd6193a48673bb2dc5451d9012eb48fe05befe473d7b0 | from django.apps import AppConfig
from django.core import checks
from django.db.models.query_utils import DeferredAttribute
from django.db.models.signals import post_migrate
from django.utils.translation import gettext_lazy as _
from . import get_user_model
from .checks import check_models_permissions, check_user_mode... |
fd035863e4739304ef637151a34d405b54be0fd97c9556f779bb7a1751817cc5 | from django.dispatch import Signal
user_logged_in = Signal(providing_args=['request', 'user'])
user_login_failed = Signal(providing_args=['credentials', 'request'])
user_logged_out = Signal(providing_args=['request', 'user'])
|
55bf757deb8a57d6b7041811d21aeb1a666f54fc34272620780fe6457f502b57 | # PermWrapper and PermLookupDict proxy the permissions system into objects that
# the template system can understand.
class PermLookupDict:
def __init__(self, user, app_label):
self.user, self.app_label = user, app_label
def __repr__(self):
return str(self.user.get_all_permissions())
def... |
e8ce7879315d08512a5b4a73cca343e11e7ef12f49af3a0f71a56dd2a0372577 | # The views used below are normally mapped in django.contrib.admin.urls.py
# This URLs file is used to provide a reliable view deployment for test purposes.
# It is also provided as a convenience to those who want to deploy these URLs
# elsewhere.
from django.contrib.auth import views
from django.urls import path
url... |
198ceee4c157e2a03d4a40549ef8960c28677ba03e3e244ab8ecec31d5202c04 | """
This module allows importing AbstractBaseUser even when django.contrib.auth is
not in INSTALLED_APPS.
"""
import unicodedata
from django.contrib.auth import password_validation
from django.contrib.auth.hashers import (
check_password, is_password_usable, make_password,
)
from django.db import models
from djang... |
a9d9eb529ecbf564c2562987d542c0a1972c68ee60ebfda213fa53e1d79ad1d6 | from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.views import redirect_to_login
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
class AccessMixin:
"""
Abstract CBV mixin that gives access mixins the same customizable
fu... |
74719909a24f842685ad7e8d22361972b5c9ae4fb9e2d92ca45f414cb9c711d3 | import unicodedata
from django import forms
from django.contrib.auth import (
authenticate, get_user_model, password_validation,
)
from django.contrib.auth.hashers import (
UNUSABLE_PASSWORD_PREFIX, identify_hasher,
)
from django.contrib.auth.tokens import default_token_generator
from django.contrib.sites.shor... |
8a1b64c1dab220d6830e2c75c3758a13d19ac9a180058f3c8fa76b574987183b | from django.conf import settings
from django.contrib import auth
from django.contrib.auth import load_backend
from django.contrib.auth.backends import RemoteUserBackend
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import MiddlewareMixin
from django.utils.functional import Simple... |
697d9faca8f50eb542b3e912bac2165086aa7dfcd75965dd039a03efb7d744fc | from urllib.parse import urlparse, urlunparse
from django.conf import settings
# Avoid shadowing the login() and logout() views below.
from django.contrib.auth import (
REDIRECT_FIELD_NAME, get_user_model, login as auth_login,
logout as auth_logout, update_session_auth_hash,
)
from django.contrib.auth.decorato... |
15a6ad29a7ebc8e8219d6f0c5913741bb6dd1cf802994162752989377c5a10bf | import functools
import gzip
import re
from difflib import SequenceMatcher
from pathlib import Path
from django.conf import settings
from django.core.exceptions import (
FieldDoesNotExist, ImproperlyConfigured, ValidationError,
)
from django.utils.functional import lazy
from django.utils.html import format_html, f... |
01794d85fc04776b289f3540b22b5b06f28b9c173d0aa746b809a3501f2610f3 | import re
from django.core import validators
from django.utils.deconstruct import deconstructible
from django.utils.translation import gettext_lazy as _
@deconstructible
class ASCIIUsernameValidator(validators.RegexValidator):
regex = r'^[\w.@+-]+$'
message = _(
'Enter a valid username. This value ma... |
8d04ba150d8fc5aa8661360d6b88ddc7ea9254f57d51fe5b4616c2f4f17404c3 | def register(*models, site=None):
"""
Register the given model(s) classes and wrapped ModelAdmin class with
admin site:
@register(Author)
class AuthorAdmin(admin.ModelAdmin):
pass
The `site` kwarg is an admin site to use instead of the default admin site.
"""
from django.contri... |
b286ce807851635f624a73c40281c728332e5266c1e22a276ba9e2643fe9b127 | import json
from django import forms
from django.conf import settings
from django.contrib.admin.utils import (
display_for_field, flatten_fieldsets, help_text_for_field, label_for_field,
lookup_field,
)
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import ManyToMany... |
78efa2574f2aa3aceb36e3e26ed6f986b432072ab6d150e4d298d648b6135c51 | 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 CSPMiddleware(MiddlewareMixin):
"""The admi... |
2b9219e89e6e8ec86ca676bab9b4efa457d306353ba7c121b1bbd6e86edf3306 | # ACTION_CHECKBOX_NAME is unused, but should stay since its import from here
# has been referenced in documentation.
from django.contrib.admin.decorators import register
from django.contrib.admin.filters import (
AllValuesFieldListFilter, BooleanFieldListFilter, ChoicesFieldListFilter,
DateFieldListFilter, Fiel... |
28b12f39f3f9c98a12138094ea7353dfa5d08fdc14855b30d8321b283104907e | import warnings
from itertools import chain
from django.apps import apps
from django.conf import settings
from django.contrib.admin.utils import (
NotRelationField, flatten, get_fields_from_path,
)
from django.core import checks
from django.core.exceptions import FieldDoesNotExist
from django.db import models
from... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.