django.core.exceptions ImproperlyConfigured Example Code

ImproperlyConfigured is a class within the Django project that is thrown when there is a mistake in an application's settings. The exception can also be thrown by a developer when building a library for project that will be used with Django.

Example 1 from django-object-tools

django-object-tools is a code library to make it easier to create new Django admin object tools. The project's code provided as open source under the BSD 3-Clause "New" or "Revised" License.

django-object-tools / object_tools / validation.py

from __future__ import unicode_literals

from django.core.exceptions import ImproperlyConfigured

__all__ = ['validate']


def validate(tool_class, model_class):
    """
    Does basic ObjectTool option validation.
    """
    if not hasattr(tool_class, 'name'):
        raise ImproperlyConfigured("No 'name' attribute found for tool %s." % (
            tool_class.__name__
        ))

    if not hasattr(tool_class, 'label'):
        raise ImproperlyConfigured("No 'label' attribute found for tool %s." % (
            tool_class.__name__
        ))

    if not hasattr(tool_class, 'view'):
        raise NotImplementedError("No 'view' method found for tool %s." % (
            tool_class.__name__
        ))
TwilioQuest logo.

Learn more Python in the awesome free TwilioQuest 16-bit adventure game.

1. Introduction 2. Development Environments 3. Data 4. Web Development 5. Deployment 6. DevOps Changelog What Full Stack Means About the Author Future Directions Page Statuses Django Code Examples django.urls.path django.conf.urls.url django.contrib.admin django.db.models Model django.dispatch Signal django.db.models.signal django.core.mail.send_mail django.core.mail.messages EmailMessage django.conf settings django.forms django.contrib.admin.sites register django.core.management.base BaseCommand django.utils.timezone django.contrib.auth get_user_model django.contrib.auth.decorators login_required django.core.exceptions ImproperlyConfigured django.utils.html format_html django.contrib.auth.hashers make_password django.http Http404 django.http HttpResponse django.http HttpResponseForbidden django.http HttpResponseBadRequest django.contrib.admin.filters SimpleListFilter django.urls.exceptions NoReverseMatch django.http HttpResponsePermanentRedirect django.http HttpResponseNotModified django.http HttpResponseRedirect django.apps.config AppConfig django.db OperationalError django.forms CharField flask_sqlalchemy.SQLAlchemy Model django.db.models CharField django.db.models TextField django.db.models BooleanField flask request flask redirect django.db.models DateTimeField django.db.models IntegerField django.db.models AutoField django.db.models DateField django.db.models FileField django.db.models SlugField django.template.response TemplateResponse django.template.response SimpleTemplateResponse SQLAlchemy Model Examples django.urls reverse_lazy Flask Core and Extensions Code Examples ...or view the full table of contents.

Full Stack Python

Full Stack Python is an open book that explains concepts in plain language and provides helpful resources for those topics.
Updates via Twitter & Facebook.

Matt Makai 2012-2019