-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_all_data.py
More file actions
28 lines (23 loc) · 817 Bytes
/
Copy pathexport_all_data.py
File metadata and controls
28 lines (23 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import django
import json
from django.core import serializers
from django.apps import apps
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BrillianBengaluru.settings")
django.setup()
all_data = []
for model in apps.get_models():
if model._meta.app_label == "admin":
continue # skip admin logs
queryset = model.objects.all()
if queryset.exists():
serialized = serializers.serialize(
"json",
queryset,
use_natural_primary_keys=True,
use_natural_foreign_keys=True
)
all_data.extend(json.loads(serialized))
with open("supabase_clean_data.json", "w", encoding="utf-8") as f:
json.dump(all_data, f, indent=4, ensure_ascii=False)
print(f"✅ Full data export complete. Total objects exported: {len(all_data)}")