Add: initial data on migration

This commit is contained in:
Aroy-Art 2025-04-02 12:49:42 +02:00
parent 4d5e661767
commit a49c6381d6
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -1,6 +1,24 @@
from django.apps import AppConfig
from django.db.models.signals import post_migrate
from django.dispatch import receiver
class ArchiveConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.archive"
@receiver(post_migrate)
def insert_defualt_data(sender, **kwargs):
from apps.archive.models import CategoryModel
categories = {
"furaffinity": "FurAffinity",
"deviantart": "DeviantArt",
"twitter": "Twitter/X",
}
if sender.name == ArchiveConfig.name:
for key, value in categories.items():
CategoryModel.objects.get_or_create(slug=key, name=value)