apps.py 821 B

123456789101112131415161718192021222324
  1. from django.apps import AppConfig
  2. from django.db import models
  3. from django.db.migrations.operations import AlterModelOptions
  4. from utilities.migration import custom_deconstruct
  5. # Ignore verbose_name & verbose_name_plural Meta options when calculating model migrations
  6. AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name')
  7. AlterModelOptions.ALTER_OPTION_KEYS.remove('verbose_name_plural')
  8. # Use our custom destructor to ignore certain attributes when calculating field migrations
  9. models.Field.deconstruct = custom_deconstruct
  10. class CoreConfig(AppConfig):
  11. name = "core"
  12. def ready(self):
  13. from core.api import schema # noqa
  14. from netbox.models.features import register_models
  15. from . import data_backends, search
  16. # Register models
  17. register_models(*self.get_models())