Python django.core.checks.register() Examples
The following are 25
code examples of django.core.checks.register().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.core.checks
, or try the search function
.
Example #1
Source File: checks.py From promgen with MIT License | 6 votes |
def sites(app_configs, **kwargs): if models.Site.objects.count() == 0: yield checks.Warning( "Site not configured", hint="Missing django site configuration", id="promgen.W006", ) for site in models.Site.objects.filter( pk=settings.SITE_ID, domain__in=["example.com"] ): yield checks.Warning( "Promgen is configured to example domain", obj=site, hint="Please update from admin page /admin/", id="promgen.W007", ) # See notes in bootstrap.py # @custom.register(checks.Tags.models)
Example #2
Source File: apps.py From django-s3file with MIT License | 6 votes |
def ready(self): from django.core.files.storage import default_storage from storages.backends.s3boto3 import S3Boto3Storage from django import forms from .forms import S3FileInputMixin if isinstance(default_storage, S3Boto3Storage) and \ S3FileInputMixin not in forms.ClearableFileInput.__bases__: forms.ClearableFileInput.__bases__ = \ (S3FileInputMixin,) + forms.ClearableFileInput.__bases__ elif S3FileInputMixin in forms.ClearableFileInput.__bases__: forms.ClearableFileInput.__bases__ = tuple( cls for cls in forms.ClearableFileInput.__bases__ if cls is not S3FileInputMixin ) checks.register(storage_check, checks.Tags.security, deploy=True)
Example #3
Source File: apps.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def ready(self): @register(Tags.compatibility, Tags.database) def check_if_postgresql(app_configs, **kwargs): if get_postgresql_connections(): return [] return [Error('You must use a PostgreSQL database ' 'to use PostgreSQL search.', id='wagtail.contrib.postgres_search.E001')] set_weights() from .models import IndexEntry IndexEntry.add_generic_relations()
Example #4
Source File: apps.py From python2017 with MIT License | 5 votes |
def ready(self): post_migrate.connect( create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions" ) checks.register(check_user_model, checks.Tags.models) checks.register(check_models_permissions, checks.Tags.models)
Example #5
Source File: apps.py From python2017 with MIT License | 5 votes |
def ready(self): checks.register(check_dependencies, checks.Tags.admin) checks.register(check_admin_app, checks.Tags.admin)
Example #6
Source File: svg.py From c3nav with Apache License 2.0 | 5 votes |
def clip_altitudes(self, new_geometry, new_altitude=None): # register new geometry with an altitude # a geometry with no altitude will reset the altitude information of its area as if nothing was ever there if self.last_altitude is not None and self.last_altitude > new_altitude: raise ValueError('Altitudes have to be ascending.') if new_altitude in self.altitudes: self.altitudes[new_altitude] = unary_union([self.altitudes[new_altitude], new_geometry]) else: self.altitudes[new_altitude] = new_geometry
Example #7
Source File: apps.py From openhgsenti with Apache License 2.0 | 5 votes |
def ready(self): post_migrate.connect(update_contenttypes) checks.register(check_generic_foreign_keys, checks.Tags.models)
Example #8
Source File: apps.py From openhgsenti with Apache License 2.0 | 5 votes |
def ready(self): post_migrate.connect(create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions") checks.register(check_user_model, checks.Tags.models)
Example #9
Source File: apps.py From openhgsenti with Apache License 2.0 | 5 votes |
def ready(self): checks.register(check_admin_app, checks.Tags.admin)
Example #10
Source File: options.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def register_with_wagtail(self): super().register_with_wagtail() @checks.register('panels') def modeladmin_model_check(app_configs, **kwargs): errors = [] for modeladmin_class in self.items: errors.extend(check_panels_in_model(modeladmin_class.model)) return errors
Example #11
Source File: options.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def register_with_wagtail(self): super().register_with_wagtail() @checks.register('panels') def modeladmin_model_check(app_configs, **kwargs): errors = check_panels_in_model(self.model, 'modeladmin') return errors
Example #12
Source File: options.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_admin_urls_for_registration(self): """ Utilised by Wagtail's 'register_admin_urls' hook to register urls for our the views that class offers. """ urls = ( url(self.url_helper.get_action_url_pattern('index'), self.index_view, name=self.url_helper.get_action_url_name('index')), url(self.url_helper.get_action_url_pattern('create'), self.create_view, name=self.url_helper.get_action_url_name('create')), url(self.url_helper.get_action_url_pattern('edit'), self.edit_view, name=self.url_helper.get_action_url_name('edit')), url(self.url_helper.get_action_url_pattern('delete'), self.delete_view, name=self.url_helper.get_action_url_name('delete')), ) if self.inspect_view_enabled: urls = urls + ( url(self.url_helper.get_action_url_pattern('inspect'), self.inspect_view, name=self.url_helper.get_action_url_name('inspect')), ) if self.is_pagemodel: urls = urls + ( url(self.url_helper.get_action_url_pattern('choose_parent'), self.choose_parent_view, name=self.url_helper.get_action_url_name('choose_parent')), ) return urls
Example #13
Source File: options.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def register_with_wagtail(self): @hooks.register('register_permissions') def register_permissions(): return self.get_permissions_for_registration() @hooks.register('register_admin_urls') def register_admin_urls(): return self.get_admin_urls_for_registration() menu_hook = ( 'register_settings_menu_item' if self.add_to_settings_menu else 'register_admin_menu_item' ) @hooks.register(menu_hook) def register_admin_menu_item(): return self.get_menu_item() # Overriding the explorer page queryset is a somewhat 'niche' / experimental # operation, so only attach that hook if we specifically opt into it # by returning True from will_modify_explorer_page_queryset if self.will_modify_explorer_page_queryset(): @hooks.register('construct_explorer_page_queryset') def construct_explorer_page_queryset(parent_page, queryset, request): return self.modify_explorer_page_queryset( parent_page, queryset, request)
Example #14
Source File: apps.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def ready(self): checks.register(check_admin_app, checks.Tags.admin)
Example #15
Source File: models.py From wagtail with BSD 3-Clause "New" or "Revised" License | 5 votes |
def register_snippet(model): if model not in SNIPPET_MODELS: model.get_usage = get_object_usage model.usage_url = get_snippet_usage_url SNIPPET_MODELS.append(model) SNIPPET_MODELS.sort(key=lambda x: x._meta.verbose_name) @checks.register('panels') def modeladmin_model_check(app_configs, **kwargs): errors = check_panels_in_model(model, 'snippets') return errors return model
Example #16
Source File: apps.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def ready(self): post_migrate.connect( create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions" ) last_login_field = getattr(get_user_model(), 'last_login', None) # Register the handler only if UserModel.last_login is a field. if isinstance(last_login_field, DeferredAttribute): from .models import update_last_login user_logged_in.connect(update_last_login, dispatch_uid='update_last_login') checks.register(check_user_model, checks.Tags.models) checks.register(check_models_permissions, checks.Tags.models)
Example #17
Source File: apps.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def ready(self): checks.register(check_finders, 'staticfiles')
Example #18
Source File: apps.py From Hands-On-Application-Development-with-PyCharm with MIT License | 5 votes |
def ready(self): checks.register(check_dependencies, checks.Tags.admin) checks.register(check_admin_app, checks.Tags.admin)
Example #19
Source File: checks.py From python-dockerflow with Mozilla Public License 2.0 | 5 votes |
def register(): check_paths = getattr( settings, "DOCKERFLOW_CHECKS", [ "dockerflow.django.checks.check_database_connected", "dockerflow.django.checks.check_migrations_applied", # 'dockerflow.django.checks.check_redis_connected', ], ) for check_path in check_paths: check = import_string(check_path) checks.register(check)
Example #20
Source File: apps.py From bioforum with MIT License | 5 votes |
def ready(self): post_migrate.connect( create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions" ) if hasattr(get_user_model(), 'last_login'): from .models import update_last_login user_logged_in.connect(update_last_login, dispatch_uid='update_last_login') checks.register(check_user_model, checks.Tags.models) checks.register(check_models_permissions, checks.Tags.models)
Example #21
Source File: apps.py From bioforum with MIT License | 5 votes |
def ready(self): checks.register(check_finders, 'staticfiles')
Example #22
Source File: apps.py From bioforum with MIT License | 5 votes |
def ready(self): checks.register(check_dependencies, checks.Tags.admin) checks.register(check_admin_app, checks.Tags.admin)
Example #23
Source File: django_checks.py From django-test-migrations with MIT License | 5 votes |
def ready(self): """That's how we register our check when apps are ready.""" checks.register(checks.Tags.compatibility)(check_migration_names)
Example #24
Source File: apps.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def ready(self): post_migrate.connect(update_contenttypes) checks.register(check_generic_foreign_keys, checks.Tags.models)
Example #25
Source File: apps.py From GTDWeb with GNU General Public License v2.0 | 5 votes |
def ready(self): post_migrate.connect(create_permissions, dispatch_uid="django.contrib.auth.management.create_permissions") checks.register(check_user_model, checks.Tags.models)