Last active
March 5, 2018 06:43
-
-
Save filipgorczynski/fab9a8a0b6bdf3bb8981e0e90ab07978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class ToastrConfig(AppConfig): | |
name = 'toastr' | |
def ready(self): | |
from .models import ToastrType, PREDEFINED_TOASTR_TYPES | |
# Prevent executing before applying migrations | |
if is_database_synchronized(DEFAULT_DB_ALIAS): | |
for title, color in PREDEFINED_TOASTR_TYPES.items(): | |
try: | |
ToastrType.objects.get(title=title) | |
except ToastrType.DoesNotExist: | |
new_toastr_type = ToastrType( | |
title=title, | |
color=color | |
) | |
new_toastr_type.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment