Skip to content

Commit 521733b

Browse files
nrjadkrygiohappy
andauthored
Add configurable project fixture loading mechanism (#591)
* feat: Add project-specific fixture loading configuration * updated the comment * Simplify error message in fixture loading --------- Co-authored-by: Giovanni Allegri <[email protected]>
1 parent eb33aed commit 521733b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/project_name/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@
7676
TEMPLATES[0]["OPTIONS"]["loaders"] = loaders
7777
TEMPLATES[0].pop("APP_DIRS", None)
7878

79+
80+
PROJECT_FIXTURES = [
81+
# List project-related fixture files here, in the order they should be loaded.
82+
]

src/tasks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ def fixtures(ctx):
402402
pty=True,
403403
)
404404

405+
# Load Project related fixtures
406+
from django.conf import settings
407+
project_fixtures = getattr(settings, 'PROJECT_FIXTURES', [])
408+
409+
for fixture in project_fixtures:
410+
if fixture:
411+
print(f"Loading project fixture: {fixture}")
412+
try:
413+
ctx.run(
414+
f"python manage.py loaddata {fixture} --settings={_localsettings()}",
415+
pty=True
416+
)
417+
except Exception as e:
418+
print(f"Warning: Failed to load fixture {fixture}: {e}")
405419

406420
@task
407421
def collectstatic(ctx):

0 commit comments

Comments
 (0)