Skip to content

Instantly share code, notes, and snippets.

@filipgorczynski
Last active March 5, 2018 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filipgorczynski/fab9a8a0b6bdf3bb8981e0e90ab07978 to your computer and use it in GitHub Desktop.
Save filipgorczynski/fab9a8a0b6bdf3bb8981e0e90ab07978 to your computer and use it in GitHub Desktop.
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