Django 1.7, Signals & AppConfig

The alpha of Django 1.7 was released recently and I’ve started to experiment with the new applications feature.

Applications include some combination of models, views, templates, template tags, static files, URLs, middleware, etc. They’re generally wired into projects with the INSTALLED_APPS setting and optionally with other mechanisms such as URLconfs, the MIDDLEWARE_CLASSES setting, or template inheritance.

The power of this feature is that it allows you to create an application configuration class which has a ready method, allowing you to perform initialization tasks such as registering signals when the application first loads.

To get started with applications, set the default_app_config variable in your application’s

Now create a new file called in the root of your application and create a class that inherits from AppConfig:

Within this class you can define a variety of things including the application’s name, verbose name and the ready method. In the example above, I’m importing the signals submodule that contains the signal receivers (in Django 1.6 and below, signal registration usually happened in the models module).

Finally, here’s an example signal and handler from my signals submodule:

4 thoughts on “Django 1.7, Signals & AppConfig”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s