{"id":18388183,"url":"https://github.com/ccnmtl/ctlsettings","last_synced_at":"2025-10-07T14:25:24.854Z","repository":{"id":65947971,"uuid":"555428034","full_name":"ccnmtl/ctlsettings","owner":"ccnmtl","description":"our common django settings (based on ccnmtlsettings)","archived":false,"fork":false,"pushed_at":"2025-03-20T15:19:43.000Z","size":93,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-20T15:41:34.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccnmtl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-21T14:59:15.000Z","updated_at":"2025-03-20T15:18:21.000Z","dependencies_parsed_at":"2023-11-10T20:27:19.943Z","dependency_job_id":"32a609a2-0b76-4173-82a3-7b4b971469f9","html_url":"https://github.com/ccnmtl/ctlsettings","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"5d8768cf3451637eeb6ae4991302a9046242c1e6"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fctlsettings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fctlsettings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fctlsettings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fctlsettings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccnmtl","download_url":"https://codeload.github.com/ccnmtl/ctlsettings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247583073,"owners_count":20961967,"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-11-06T01:31:59.898Z","updated_at":"2025-10-07T14:25:24.784Z","avatar_url":"https://github.com/ccnmtl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/ccnmtl/ctlsettings/workflows/build-and-test/badge.svg)](https://github.com/ccnmtl/ctlsettings/actions)\n\nThese are the common settings we use across all our Django apps,\nextracted into a handy reusable module.\n\n## Usage\n\n### Installation\n\nFirst, install it with\n\n    $ pip install ctlsettings\n\nor add `ctlsettings==0.3.3` to your `requirements.txt`.\n\n### Dependencies\n\nThe following libraries are used in some way, so they'll need to be installed:\n\n* django-cas-ng\n* django-debug-toolbar\n* coverage\n* django-smoketest\n* django-extensions\n* django-statsd-mozilla\n* django-storages\n* django-impersonate\n* boto3\n* sentry-sdk\n* statsd\n* gunicorn\n\n### Use it\n\n`ctlsettings` has three \"environments\" (for now) that you will want\nto make use of: `shared`, `staging`, and `production`.\n\nIn your `settings_shared.py` you will want to do something like:\n\n    import os.path\n    from ctlsettings.shared import common\n\n    project = 'yourapp'\n    base = os.path.dirname(__file__)\n\n    locals().update(common(project=project, base=base))\n\n    # which apps should jenkins include in coverage reports?\n    PROJECT_APPS = [\n        'yourapp.main',\n    ]\n\n    INSTALLED_APPS += [  # noqa\n        'yourapp.main',\n    ]\n\n\nMost of the magic is on the `locals().update(...)` line. That's where\nthe `common` function from `ctlsettings.shared` is called with\nsimple configuration and returns a bunch of variables, which are then\ninjected into the local symbol table. The two requires parameters are\n`project` and `base`.\n\n`project` is the name of your project. It should be lowercase with\njust alphanumeric characters. Most likely, just the name of the\ndirectory for your project.\n\n`base` is the full path of the directory that `settings_shared.py` is\nin.\n\nAfter that, a few settings that `ctlsettings` can't fully set up are\nset and/or modified. In particular, the project's apps are added to\n`INSTALLED_APPS`.\n\nAn important note is that because of the weird symbol table tweaking\ndone earlier, flake8 will complain if you try to modify a variable\nthat comes out of `ctlsettings`, since it didn't see where it got\ndefined. You need to add the `# noqa` line to each variable that you\nmodify this way to get it to ignore it.\n\nYou'll do almost the same thing for your `settings_staging.py` and\n`settings_production.py`:\n\n    from myapp.settings_shared import *\n    from ctlsettings.staging import common\n    import os\n\n    project = 'yourapp'\n    base = os.path.dirname(__file__)\n\n    locals().update(\n        common(\n            project=project,\n            base=base,\n            STATIC_ROOT=STATIC_ROOT,\n            INSTALLED_APPS=INSTALLED_APPS,\n            cloudfront='some-cloudfront-id',\n        ))\n\n    try:\n        from myapp.local_settings import *\n    except ImportError:\n        pass\n\n(and the same thing for `settings_production.py`, but with `from\nctlsettings.production import common` instead.)\n\nAgain, you are passing in `project`, and `base`. The\nstaging/production settings also need to have access to `STATIC_ROOT`\nand `INSTALLED_APPS`, so those must be passed in.\n\nFinally, there are a couple variables related to static file\ndeployment that you may or may not want to set:\n\n`s3static` is a boolean. It defaults to `True` and tells\n`ctlsettings` that you are using S3 for serving static\nfiles. Mainly, you will want to set this to `False` if your\napplication is not yet serving static files off S3.\n\n`cloudfront` is a cloudfront id. If you pass it in, AWS Cloudfront\nwill be used for the static files URLs.\n\n## Recommendations\n\nIf you're converting an existing app to `ctlsettings`, which I\nrecommend is:\n\n* install `ctlsettings` and any libraries it requires\n* add the `ctlsettings` related stuff to the top of your\n  `settings_shared.py` and set up the basic configuration, but leave\n  all your settings in place after it (effectively overriding\n  everything that `ctlsettings` is pulling in).\n* pull up\n  https://github.com/ccnmtl/ctlsettings/blob/master/ctlsettings/shared.py\n  in a browser.\n* line by line, setting by setting, compare what you have in your\n  `settings_shared.py` with what `ctlsettings` has for the same\n  variable. Delete yours if they are the same. Otherwise leave yours\n  in place (or append the differences if it's a list variable).\n* run your tests/flake8 each time.\n* do the same for staging/production.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnmtl%2Fctlsettings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccnmtl%2Fctlsettings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnmtl%2Fctlsettings/lists"}