{"id":18388184,"url":"https://github.com/ccnmtl/ccnmtlsettings","last_synced_at":"2025-04-07T02:33:09.963Z","repository":{"id":1370618,"uuid":"42588187","full_name":"ccnmtl/ccnmtlsettings","owner":"ccnmtl","description":"our common django settings","archived":true,"fork":false,"pushed_at":"2025-02-26T16:38:11.000Z","size":103,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T05:47:32.612Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccnmtl.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"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":"2015-09-16T13:16:51.000Z","updated_at":"2025-02-26T16:39:02.000Z","dependencies_parsed_at":"2024-11-06T02:04:36.283Z","dependency_job_id":null,"html_url":"https://github.com/ccnmtl/ccnmtlsettings","commit_stats":{"total_commits":100,"total_committers":6,"mean_commits":"16.666666666666668","dds":0.61,"last_synced_commit":"e22b9338e67a62ce58afac4c1c4b8dbb9be56f15"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fccnmtlsettings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fccnmtlsettings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fccnmtlsettings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccnmtl%2Fccnmtlsettings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccnmtl","download_url":"https://codeload.github.com/ccnmtl/ccnmtlsettings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247583072,"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:32:05.519Z","updated_at":"2025-04-07T02:33:09.948Z","avatar_url":"https://github.com/ccnmtl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project is deprecated in favor of [ctlsettings](https://github.com/ccnmtl/ctlsettings).\n\n--\n\n[![Actions Status](https://github.com/ccnmtl/ccnmtlsettings/workflows/build-and-test/badge.svg)](https://github.com/ccnmtl/ccnmtlsettings/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 ccnmtlsettings\n\nor add `ccnmtlsettings==0.1.0` 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_compressor\n* django-debug-toolbar\n* coverage\n* django-smoketest\n* django-extensions\n* django-statsd-mozilla\n* django-markwhat\n* django-storages\n* django-impersonate\n* boto3\n* sentry-sdk\n* statsd\n* gunicorn\n* djangowind\n\n### Use it\n\n`ccnmtlsettings` 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\timport os.path\n\tfrom ccnmtlsettings.shared import common\n\n\tproject = 'yourapp'\n\tbase = os.path.dirname(__file__)\n\n\tlocals().update(common(project=project, base=base))\n\n    # which apps should jenkins include in coverage reports?\n\tPROJECT_APPS = [\n\t\t'yourapp.main',\n\t]\n\n\tINSTALLED_APPS += [  # noqa\n\t\t'yourapp.main',\n\t]\n\n\nMost of the magic is on the `locals().update(...)` line. That's where\nthe `common` function from `ccnmtlsettings.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 `ccnmtlsettings` 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 `ccnmtlsettings`, 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\tfrom myapp.settings_shared import *\n\tfrom ccnmtlsettings.staging import common\n\timport os\n\n\tproject = 'yourapp'\n\tbase = os.path.dirname(__file__)\n\n\tlocals().update(\n\t\tcommon(\n\t\t\tproject=project,\n\t\t\tbase=base,\n\t\t\tSTATIC_ROOT=STATIC_ROOT,\n\t\t\tINSTALLED_APPS=INSTALLED_APPS,\n\t\t\tcloudfront='some-cloudfront-id',\n\t\t))\n\n\ttry:\n\t\tfrom myapp.local_settings import *\n\texcept ImportError:\n\t\tpass\n\n(and the same thing for `settings_production.py`, but with `from\nccnmtlsettings.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`ccnmtlsettings` 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 `ccnmtlsettings`, which I\nrecommend is:\n\n* install `ccnmtlsettings` and any libraries it requires\n* add the `ccnmtlsettings` 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 `ccnmtlsettings` is pulling in).\n* pull up\n  https://github.com/ccnmtl/ccnmtlsettings/blob/master/ccnmtlsettings/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 `ccnmtlsettings` 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%2Fccnmtlsettings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccnmtl%2Fccnmtlsettings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccnmtl%2Fccnmtlsettings/lists"}