django_utils.management.commands package

Submodules

django_utils.management.commands.admin_autogen module

class django_utils.management.commands.admin_autogen.Command(*args: Any, **kwargs: Any)[source]

Bases: CustomBaseCommand

handle(*args: Any, **kwargs: Any) → None[source]

The actual logic of the command. Subclasses must implement this method.

django_utils.management.commands.base_command module

class django_utils.management.commands.base_command.ChunkedCommand(*args: Any, **kwargs: Any)[source]

Bases: CustomBaseCommand

Batch-process a queryset in bounded, resumable chunks.

Subclasses implement get_queryset() and handle_instance(); the base iterates via queryset_iterator (memory bounded on both the client and the database), logs progress with a rate every --log-every rows, stops after --limit rows, resumes after a known pk with --resume-from, and rolls everything back under --dry-run. On interrupt or early stop it logs the exact --resume-from value to continue with.

--dry-run wraps only the queryset's own database alias (self.get_queryset().db); writes handle_instance makes to OTHER databases are not covered and will still be committed. Also note: under --dry-run, the resume hints logged refer to work that was rolled back -- do not feed them to a real run.

Deliberately out of scope: retries and parallelism. This is iterate + log + checkpoint, nothing more.

add_arguments(parser: CommandParser) → None[source]

Entry point for subclassed commands to add custom arguments.

chunksize: ClassVar[int] = 1000
get_queryset() → QuerySet[source]

Return the queryset to process. Subclasses must implement.

handle(*args: Any, **options: Any) → str | None[source]

The actual logic of the command. Subclasses must implement this method.

handle_instance(instance: Any) → None[source]

Process one row. Subclasses must implement.

log_every: ClassVar[int] = 1000
class django_utils.management.commands.base_command.CustomAppCommand(*args: Any, **kwargs: Any)[source]

Bases: CustomBaseCommand, AppCommand

class django_utils.management.commands.base_command.CustomBaseCommand(*args: Any, **kwargs: Any)[source]

Bases: BaseCommand, Logged

create_logger() → Logger[source]
handle(*args: Any, **kwargs: Any) → str | None[source]

The actual logic of the command. Subclasses must implement this method.

loggers: ClassVar[tuple[str, ...]] = ()

django_utils.management.commands.settings module

class django_utils.management.commands.settings.Command(*args: Any, **kwargs: Any)[source]

Bases: CustomBaseCommand

add_arguments(parser: ArgumentParser) → None[source]

Entry point for subclassed commands to add custom arguments.

can_import_settings = True
handle(*args: Any, **options: Any) → None[source]

The actual logic of the command. Subclasses must implement this method.

help = 'Get a list of the current settings, any arguments given will be\n    used to match the settings name (case insensitive).\n    '
output_types: ClassVar[tuple[str, ...]] = ('pprint', 'print', 'json', 'csv')
render_output(data: dict[str, Any] | None, output_type: str | None = 'pprint', show_keys: bool = False, **options: Any) → None[source]
requires_model_validation = False
django_utils.management.commands.settings.json_default(obj: Any) → str[source]

Module contents