Add: initial data on migration
This commit is contained in:
parent
4d5e661767
commit
a49c6381d6
1 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue