You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

apps.py 797B

12345678910111213141516171819202122
  1. from django.apps import AppConfig
  2. from django.contrib.contenttypes.checks import (
  3. check_generic_foreign_keys, check_model_name_lengths,
  4. )
  5. from django.core import checks
  6. from django.db.models.signals import post_migrate, pre_migrate
  7. from django.utils.translation import gettext_lazy as _
  8. from .management import (
  9. create_contenttypes, inject_rename_contenttypes_operations,
  10. )
  11. class ContentTypesConfig(AppConfig):
  12. name = 'django.contrib.contenttypes'
  13. verbose_name = _("Content Types")
  14. def ready(self):
  15. pre_migrate.connect(inject_rename_contenttypes_operations, sender=self)
  16. post_migrate.connect(create_contenttypes)
  17. checks.register(check_generic_foreign_keys, checks.Tags.models)
  18. checks.register(check_model_name_lengths, checks.Tags.models)