Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove post migrate handler with a default instance creation via Migration #219

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions admin_interface/apps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from django.apps import AppConfig
from django.db.models.signals import post_migrate

from admin_interface.compat import gettext_lazy as _

Expand All @@ -15,7 +14,5 @@ class AdminInterfaceConfig(AppConfig):
def ready(self):

from admin_interface import settings
from admin_interface.models import Theme

settings.check_installed_apps()
post_migrate.connect(Theme.post_migrate_handler, sender=self)
4 changes: 4 additions & 0 deletions admin_interface/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@


class Migration(migrations.Migration):
def create_default_theme(apps, schema_editor):
VaZark marked this conversation as resolved.
Show resolved Hide resolved
Theme = apps.get_model("admin_interface", "Theme")
Theme.objects.create()

dependencies = []

Expand Down Expand Up @@ -225,4 +228,5 @@ class Migration(migrations.Migration):
"verbose_name_plural": "Themes",
},
),
migrations.RunPython(create_default_theme),
VaZark marked this conversation as resolved.
Show resolved Hide resolved
]
6 changes: 0 additions & 6 deletions admin_interface/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@

@python_2_unicode_compatible
class Theme(models.Model):
@staticmethod
def post_migrate_handler(**kwargs):
del_cached_active_theme()
db = kwargs["using"]
Theme.get_active_theme(database=db)

@staticmethod
def post_delete_handler(**kwargs):
del_cached_active_theme()
Expand Down