Defining overwritable app settings

This recipe will show you how to define settings for your app that can be then overwritten in your project's settings.py or local_settings.py file. This is useful especially for reusable apps.

Getting ready

Either create your Django app manually or using the following command:

(myproject_env)$ django-admin.py startapp myapp1

How to do it…

If you just have one or two settings, you can use the following pattern in your models.py file. If the settings are extensive and you want to have them organized better, create an app_settings.py file in the app and put the settings in the following way:

# models.py or app_settings.py # -*- coding: UTF-8 -*- from __future__ import unicode_literals from django.conf import settings ...

Get Django: Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.