From 32cf3becb6603d10a4360dd3cbb4f6b27ae78095 Mon Sep 17 00:00:00 2001 From: irfanpule Date: Fri, 29 May 2020 14:15:21 +0700 Subject: [PATCH] fix error migrate --- .../commands/seeding_initial_settings.py | 16 ++++++++++++++++ .../offices/migrations/0009_setting_favicon.py | 16 +--------------- readme.md | 6 ++++++ 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 academy/apps/offices/management/commands/seeding_initial_settings.py diff --git a/academy/apps/offices/management/commands/seeding_initial_settings.py b/academy/apps/offices/management/commands/seeding_initial_settings.py new file mode 100644 index 0000000..bd54a7c --- /dev/null +++ b/academy/apps/offices/management/commands/seeding_initial_settings.py @@ -0,0 +1,16 @@ +from django.core.management.base import BaseCommand +from academy.apps.offices.models import Setting + + +class Command(BaseCommand): + help = 'To Seeding Initial Settings data' + + def handle(self, *args, **options): + Setting.objects.update_or_create( + name="Apperance", + defaults={ + 'site_name': 'NolSatu', + 'footer_title': 'PT. Boer Technology (Btech)', + 'footer_url': 'https://btech.id/', + } + ) diff --git a/academy/apps/offices/migrations/0009_setting_favicon.py b/academy/apps/offices/migrations/0009_setting_favicon.py index 2109ad4..59b4f5f 100644 --- a/academy/apps/offices/migrations/0009_setting_favicon.py +++ b/academy/apps/offices/migrations/0009_setting_favicon.py @@ -1,19 +1,6 @@ # Generated by Django 2.2.10 on 2020-04-06 04:53 from django.db import migrations, models -from academy.apps.offices.models import Setting - - -def initial_apperance(apps, schema_editor): - # initial apperance setting data - Setting.objects.update_or_create( - name="Apperance", - defaults={ - 'site_name': 'NolSatu', - 'footer_title': 'PT. Boer Technology (Btech)', - 'footer_url': 'https://btech.id/', - } - ) class Migration(migrations.Migration): @@ -27,6 +14,5 @@ class Migration(migrations.Migration): model_name='setting', name='favicon', field=models.ImageField(blank=True, null=True, upload_to='images/settings'), - ), - migrations.RunPython(initial_apperance), + ) ] diff --git a/readme.md b/readme.md index caa8a6c..0996454 100644 --- a/readme.md +++ b/readme.md @@ -27,6 +27,12 @@ Migrate database $ python manage.py migrate ``` +Run this command to seeding initial data settings + +``` +$ python manage.py seeding_initial_settings +``` + Collect Static ```