{"id":13937220,"url":"https://github.com/jaredly/django-appsettings","last_synced_at":"2025-07-05T23:03:48.156Z","repository":{"id":57418972,"uuid":"539558","full_name":"jaredly/django-appsettings","owner":"jaredly","description":"A unified settings system for reusable django apps","archived":false,"fork":false,"pushed_at":"2013-07-21T05:22:02.000Z","size":82,"stargazers_count":88,"open_issues_count":8,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-27T12:11:37.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jaredforsyth.com/projects/app-settings","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredly.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-02-28T08:42:56.000Z","updated_at":"2023-05-17T21:56:51.000Z","dependencies_parsed_at":"2022-09-13T08:00:51.826Z","dependency_job_id":null,"html_url":"https://github.com/jaredly/django-appsettings","commit_stats":null,"previous_names":["jabapyth/django-appsettings"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jaredly/django-appsettings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fdjango-appsettings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fdjango-appsettings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fdjango-appsettings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fdjango-appsettings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredly","download_url":"https://codeload.github.com/jaredly/django-appsettings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fdjango-appsettings/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263819137,"owners_count":23516115,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-07T23:03:23.945Z","updated_at":"2025-07-05T23:03:48.095Z","avatar_url":"https://github.com/jaredly.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"Django appsettings\n==================\n\nfinally, a unified system for pluggable apps to have configurable settings.\nthe django-appsettings app provides a clean api for keeping track of settings,\nand, most importantly, having settings that are configurable for a user that\ndoes not have write access to your server :) appsettings also provides an\ninterface (similar to the admin interface for models) for editing these\nsettings.\n\nFeatures\n--------\n\n- an organized system for managing settings\n- degrades gracefully when there's no database (settings will just be read-only)\n- uses forms.Field classes to store setting types -- totally customizeable for\n  - validation\n  - serialization\n  - display widgets\n- supports full user overrides in project/settings.py\n- **new:** special flags for *readonly* and *global* groups\n- **new:** support for caching\n- **new:** middleware to limit database access.\n\nTodo\n----\n\n- improve the web interface\n- add import/export via conf files\n\nUsage\n=====\n\nSo you want to use this in your app? Well, just create a settings.py for your\napp (which will be auto-loaded by appsettings in the same way contrib.admin\nloads your admin.py) and register your settings. Example::\n\n    import appsettings\n    from django import forms\n    register = appsettings.register('mymodule')\n\n    # settings are organized into groups.\n    # this will define settings\n    #   mymodule.story.greeting, \n    #   mymodule.story.pigs,\n    #   etc.\n    @register\n    class Story:\n        # int, string, and float types are auto-discovered.\n        greeting = \"hello\"\n        pigs = 3\n        wolves = 1\n        # or you can specify the type\n        houses = forms.IntegerField(initial = 3, doc = \"number of houses in which to hide\")\n        myhouse = forms.ChoiceField(choices = (('straw', 'Straw'),\n                                             ('sticks', 'Sticks'),\n                                             ('bricks', 'Bricks')),\n                                    initial = 'straw')\n\nUsing the settings in the rest of your app couldn't be easier::\n\n    from appsettings import app\n    settings = app.settings.mymodule\n\n    def run_away():\n        return \"%s pigs are running into a house made of %s\" \\\n                        % (settings.story.pigs, settings.story.myhouse)\n\nTo enable users to edit the settings from the front end, add the following line to urls.py::\n\n    url(r'^appsettings/', include('appsettings.urls')),\n\nIf a user change the settings (from the front end) then they will be saved to the database. The settings will then be retrieved from the database whenever they are used. Retrieving the settings from the database in this way could be time / resource expensive so there are two options to speed this up:\n\n1. Enable caching.\n\n If caching is enabled the settings will be stored in the cache at initialisation time then retrieved and set to the cache whenever the settings are accessed or changed. As long as the cache backend supports cross-process caching then all threads will share the same settings.\n\n To enable caching, add the following line to your main settings.py::\n\n    APPSETTINGS_USE_CACHE = True\n\n and set CACHE_BACKEND to something that supports cross-process caching (i.e.: NOT 'locmem://')\n\n2. Use the SettingsMiddleware\n\n The SettingsMiddleware will copy all the settings stored in the database into the current request (thread) at the start of the request so that they do not need to be retrieved eache time they are accessed (during the request). \n\n To use the middleware add ''appsettings.middleware.SettingsMiddleware' to the MIDDLEWARE_CLASSES in your project's setttings.py\n\n e.g::\n\n    MIDDLEWARE_CLASSES = (\n        'django.middleware.common.CommonMiddleware',\n        'django.contrib.sessions.middleware.SessionMiddleware',\n        'django.contrib.auth.middleware.AuthenticationMiddleware',\n        'appsettings.middleware.SettingsMiddleware',\n    )\n\n.. note::\n\n    As you can see, group names are converted to *lowercase* when accessing.\n    This is to follow the django convention set in models and other areas, and\n    because I think it looks better. If you have a good argument either way,\n    feel free to make an `issue \u003chttp://github.com/jabapyth/django-appsettings/issues\u003e`_.\n\nSpecial Flags\n-------------\n\nappsettings also supports a few special flags, to make settings management\neasier. Currently *readonly* and *main* are supported. *readonly* makes\na settings group, as you can imagine, read-only; they never interact with the\ndatabase. *main* makes the settings accessible outside of their group.\nSee example::\n\n    ## -- walks/settings.py --\n    import appsettings\n    register = appsettings.register('walks')\n\n    @register(main=True)\n    class Globals:\n        spam = 'spam and eggs'\n\n    ## -- somewhere_else.py --\n\n    import appsettings\n    settings = appsettings.settings.walks\n\n    print settings.spam ## gets routed to settings.globals.spam\n    print settings.globals.spam\n\nNote that you can only have one settings group flagged as \"main\".\n\n.. note::\n\n    If you're using Python \u003c= 2.5, the @decorator syntax won't work for\n    classes.  In that case, after your class declaration put the line\n    ``Globals = register(main=True)(Globals)``. See the `PEP\n    \u003chttp://www.python.org/dev/peps/pep-0318/#motivation\u003e`_.\n\nPlease give me feedback and any questions through github\nhttp://github.com/jabapyth/django-appsettings\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fdjango-appsettings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredly%2Fdjango-appsettings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fdjango-appsettings/lists"}