Skip to main content

Command

This class outputs the contents of the database as a fixture of a specified format. It supports filtering by application or model, excluding specific data, and utilizing natural keys for serialization. Users can customize the output through various options such as indentation, database selection, and primary key filtering.

Attributes

AttributeTypeDescription
helpstringOutput the contents of the database as a fixture of the given format (using each model's default manager unless --all is specified).

Methods


add_arguments()

@classmethod
def add_arguments(
parser: [CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)
)

Configures the command-line argument parser with options for filtering data, selecting output formats, and specifying the target database.

Parameters

NameTypeDescription
parser[CommandParser](../../base/commandparser.md?sid=django_core_management_base_commandparser)The argument parser instance to which dumpdata-specific arguments like --format, --indent, and --exclude are added.

handle()

@classmethod
def handle(
app_labels: str,
options: dict
) - > null

Output the contents of the database as a fixture of the given format (using each model's default manager unless --all is specified).

Parameters

NameTypeDescription
app_labelsstrOptional list of app labels or app_label.ModelName strings to restrict the data being dumped.
optionsdictA dictionary of parsed command-line arguments including 'format', 'indent', 'database', and 'output' path.

Returns

TypeDescription
nullThe method writes serialized data directly to a file or stdout and does not return a value.