fairdm.management.commands.generate_fake_data#
Management command that generates fake data for development.
This command creates a complete hierarchy of fake data including projects, datasets, samples, and measurements. It uses polymorphic Sample and Measurement subclasses configured via the FAIRDM_FACTORIES setting.
Configuration: Add your custom factory classes to settings.py:
FAIRDM_FACTORIES = {
"myapp.CustomSample": "myapp.factories.CustomSampleFactory",
"myapp.SpecialMeasurement": "myapp.factories.SpecialMeasurementFactory",
}
The command will randomly use these factories to create polymorphic instances.
If no factories are configured, samples and/or measurements are skipped rather than
falling back to the base ``Sample``/``Measurement`` models - neither can be created
directly.
Usage: uv run python manage.py generate_fake_data uv run python manage.py generate_fake_data –projects 5 –datasets 3 uv run python manage.py generate_fake_data –clear
Module Contents#
Classes#
Generate a hierarchy of fake projects, datasets, samples and measurements. |
API#
- class Command(stdout=None, stderr=None, no_color=False, force_color=False)#
Bases:
django.core.management.base.BaseCommandGenerate a hierarchy of fake projects, datasets, samples and measurements.
Initialization
- help#
‘Generate fake data for development purposes’
- add_arguments(parser)#
Add the options that size the generated data.
- handle(*args, **options)#
Generate the requested data, clearing existing records first when asked.