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
| Attribute | Type | Description |
|---|---|---|
| help | string | Output 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
| Name | Type | Description |
|---|---|---|
| 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
| Name | Type | Description |
|---|---|---|
| app_labels | str | Optional list of app labels or app_label.ModelName strings to restrict the data being dumped. |
| options | dict | A dictionary of parsed command-line arguments including 'format', 'indent', 'database', and 'output' path. |
Returns
| Type | Description |
|---|---|
null | The method writes serialized data directly to a file or stdout and does not return a value. |