apps.py 676 Bytes
from django.apps import AppConfig
from django.conf import settings

class PyrosappConfig(AppConfig):
    name = 'pyrosapp'

    def ready(self):
        from pyrosapp.models import Version
        AppConfig.ready(self)
        versions = settings.MODULES_VERSIONS

        for module, version in versions.items():
            same_module_versions = Version.objects.filter(module_name=module)
            if same_module_versions.count() == 0:
                Version.objects.create(module_name=module, version=version)
            elif same_module_versions.order_by("-created")[0].version != version:
                Version.objects.create(module_name=module, version=version)