Skip to main content

Includes the guardedsettings.py and projectbuilder.py modules under Apache 2.0 LICENSE.

Project description

For use within Django.

There are two Python modules

guardedsettings.py projectbuilder.py

guardedsettings

For use within a Django settings.py file. It allows a Django project to ship and not incorporate secret information in the settings.py file, such as the SECRET_KEY and DATABASE:PASSWORD.

When the guardedsettings program starts, it reads the guardedsettings.json file and creates a Python dictionary from guardedsettings.json content. The JSON is referenced by using the method, SettingsDictionary['Key In The JSON'].

guardedsettings.json

In the Django Project Root, where the manage.py file resides, you create a JSON file named guardedsettings.JSON as such.

{ "SecretKey": "Secret", "DatabasePassword" : "MoreSecret" }

Consider the line containing

"SecretKey": "Secret",

The term "SecretKey" is a key and the term "Secret" is the value. Together they are called a pair, hence the term 'key/value pair'.

Add as many key/value pairs as necessary, each separated by a comma.

settings.py

Use guardedsettings within the Django settings.py file as shown below. Place the two lines of code close to or at the top of the settings.py file.

--- At Or Near The Top of settings.py

from UA_GuardedSettings import guardedsettings gs = guardedsettings.guardedsettings()

---

An instance of guardedsettings is now instantiated as the variable named 'gs'. You are welcome to name the variable as you choose.

Later in the settings.py, use guardedsettings as shown.

The generic form of usage is

SomeDjangoSetting = gs.SettingsDictionary['SomeKey']

For example

-- in the settings.py file

SECRET_KEY = gs.SettingsDictionary['SecretKey']

and like so for a database password.

-- in the settings.py file DATABASE section.

'PASSWORD' : gs.SettingsDictionary['databasePassword'],

projectbuilder.py

The goal of projectbuilder is to package an existing Django Project (not the apps), and create a package under a new name - for use as a Site in a deployment.

This alleviates the need to create a new Django Project in each deployment phase; testing, staging and production, among others your organization may employ.

projectbuilder must run in the 'Project Root', where the Django manage.py folder resides.

The program requires two inputs. (1) The name of the existing Django project to package. (2) The name of the new Django Project to create.

The new package will be completely referenced to the new name you provide. The manage.py will be re-referenced, as is the asgi.py, settings.py and, the wsgi.py files, all referencing the new project.

It will build a zip file in the RootFolder\dist\projects folder and is named with '_Project.zip' preceding the project name you input as the new name.

Transport this zip file to a new deployment site and unzip it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ua_djangolibrary-0.6.6.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ua_djangolibrary-0.6.6-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file ua_djangolibrary-0.6.6.tar.gz.

File metadata

  • Download URL: ua_djangolibrary-0.6.6.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for ua_djangolibrary-0.6.6.tar.gz
Algorithm Hash digest
SHA256 2c0adad1878f9dc49406d1cf9b4f141ffeba5f2aba6b886ce707e7e748dbcec8
MD5 bd42066f57bb28416da2166cfc577a45
BLAKE2b-256 bcf86a69b07dd0a91742d7511521d9eda8e38948a17a31d1354bd325f9759a10

See more details on using hashes here.

File details

Details for the file ua_djangolibrary-0.6.6-py3-none-any.whl.

File metadata

File hashes

Hashes for ua_djangolibrary-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0164736f20bb218772112b1490f94163b1d36409f0dd08122988180e879754e1
MD5 c09f7dbf3caa95792557b30fd82862b3
BLAKE2b-256 44cfffb3e839a8992ee2d1307ec8a0af87a50d5d0f2b983885d9507473234c72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page