{"id":19177801,"url":"https://github.com/andrewsomething/python-django","last_synced_at":"2026-06-17T04:31:29.683Z","repository":{"id":9880438,"uuid":"11883062","full_name":"andrewsomething/python-django","owner":"andrewsomething","description":"Mirror of juju charm, pull requests and modifications welcome!","archived":false,"fork":false,"pushed_at":"2013-08-04T18:55:51.000Z","size":297,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T01:23:51.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jujucharms.com/charms/precise/python-django","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewsomething.png","metadata":{"files":{"readme":"README.md","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":"2013-08-04T18:41:09.000Z","updated_at":"2016-01-29T15:09:44.000Z","dependencies_parsed_at":"2022-09-06T04:51:52.626Z","dependency_job_id":null,"html_url":"https://github.com/andrewsomething/python-django","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andrewsomething/python-django","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewsomething%2Fpython-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewsomething%2Fpython-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewsomething%2Fpython-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewsomething%2Fpython-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewsomething","download_url":"https://codeload.github.com/andrewsomething/python-django/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewsomething%2Fpython-django/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34434492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-09T10:35:12.242Z","updated_at":"2026-06-17T04:31:29.665Z","avatar_url":"https://github.com/andrewsomething.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python-django Charm\n\nAuthors: \n\n- Patrick Hetu \u003cpatrick.hetu@gmail.com\u003e \n- Bruno Girin\n\n## What is Django?\n\nDjango is a high-level web application framework that loosely follows\nthe model-view-controller design pattern.  Python's equivalent to Ruby\non Rails, Django lets you build complex data-driven websites quickly\nand easily - Django focuses on automating as much as possible and\nadhering to the \"Don't Repeat Yourself\" (DRY) principle.  Django\nadditionally emphasizes reusability and \"pluggability\" of components;\nmany generic third-party \"applications\" are available to enhance\nprojects or to simply to reduce development time even further.\n\nNotable features include: \n\n- An object-relational mapper (ORM)\n- Automatic admin interface\n- Elegant URL dispatcher\n- Form serialization and validation system\n- Templating system\n- Lightweight, standalone web server for development and testing\n- Internationalization support\n- Testing framework and client\n\n## The charm\n\n\nThis charm will install Django. It can also install your Django\nproject and his dependencies from either a template or from a\nversion control system.\n\nIt can also link your project to a database and sync the schemas.\nThis charm also come with a Fabric fabfile to interact with the\ndeployement in a cloud aware manner.\n\n\n## Quick start\n\nSimply::\n    \n    juju bootstrap\n    juju deploy python-django\n\n    juju deploy postgresql\n    juju add-relation python-django postgresql:db\n\n    juju deploy gunicorn\n    juju add-relation python-django gunicorn\n    juju expose python-django\n\nIn a couple of minute, your new (vanilla) Django site should be ready at\nthe public address of gunicorn. You can find it in the output of the\n`juju status` command.  \n\nThis is roughtly equivalent to the [Creating a project](https://docs.djangoproject.com/en/1.5/intro/tutorial01/#creating-a-project) step in Django's\ntutorial.\n\n### Example: Deploying using site a template\n\n1. Setup your Django specific parameters in mydjangosite.yaml like this one::\n\n    mydjangosite:\n         project_template_url: https://github.com/xenith/django-base-template/zipball/master\n         project_template_extension: py,md,rst\n\nNote: If your using juju-core you must remove the first line\nof the file and the indentation for the rest of the file.\n\n1. Deployment with `Gunicorn`::\n\n    juju bootstrap\n    juju deploy --config mydjangosite.yaml mydjangosite\n\n    juju deploy postgresql\n    juju add-relation mydjangosite postgresql:db\n\n    juju deploy gunicorn\n    juju add-relation mydjangosite gunicorn\n    juju expose mydjangosite\n\n\n### Example: Deploying using code repository\n\n1. Setup your Django specific parameters in mydjangosite.yaml like this one::\n\n    mydjangosite:\n        vcs: bzr\n        repos_url: lp:~patrick-hetu/my_site\n\nNote: \n\nIf your using juju-core you must remove the first line\nof the file and the indentation for the rest of the file.\n\n1. Deployment with `Gunicorn`::\n\n        juju bootstrap\n        juju deploy --config mydjangosite.yaml python-django\n\n        juju deploy postgresql\n        juju add-relation python-django postgresql:db\n\n        juju deploy gunicorn\n        juju add-relation python-django gunicorn\n        juju expose python-django\n\nNote: If your using juju-core you must add --upload-tools to the\n`juju bootstrap` command.\n\n1. Accessing your new Django site should be ready at the public address of\n   Gunicorn. To find it look for it in the output of the `juju status` command.  \n\n## Project layout and code injection\n\nTaking the previous example, your web site should be on the Django node at:\n\n    /srv/python-django/\n\nAs you can see there the charm have inject some code at the end of your settings.py\nfile (or created it if it was not there) to be able to import what's in the\n`juju_settings/` directory.\n\nIt's recommended to make your vcs to ignore database and secret files or\nany files that have information that you don't want to be publish.\n\n## Upgrade the charm\n\nThis charm allow you to upgrade your deployment using the Juju's\n`upgrade-charm` command. This command will:\n\n- upgrade Django\n- upgrade additionnal pip packages\n- upgrade additionnal Debian packages\n- upgrade using requirements files in your project\n\n## Management with Fabric\n\n[Fabric](http://docs.fabfile.org) is a Python (2.5 or higher) library and command-line tool for\nstreamlining the use of SSH for application deployment or systems\nadministration tasks.\n\nIt provides a basic suite of operations for executing\nlocal or remote shell commands (normally or via sudo) and uploading/downloading\nfiles, as well as auxiliary functionality such as prompting the running user\nfor input, or aborting execution.\n\nThis charm includes a Fabric script that use Juju's information to perform various\ntasks.\n\nFor a list of tasks type this command after bootstraping your Juju environment::\n\n    fab -l\n\nFor example, with a python-django service deployed you can run commands on all its units::\n\n    fab -R python-django pull\n    [10.0.0.2] Executing task 'pull'\n    [10.0.0.2] run: bzr pull lp:~my_name/django_code/my_site\n    ...\n    [10.0.0.2] run: invoke-rc.d gunicorn restart\n    ...\n\nOr you can also run commands on a single unit::\n\n    fab -R python-django/0 manage:createsuperuser\n    ...\n    [10.0.0.2] out: Username (leave blank to use 'ubuntu'):\n\n\nLimitation:\n\n- You can only execute task for one role at the time.\n  But it can be a service or unit.\n\nIf you want to extend the fabfile check out [fabtools](http://fabtools.readthedocs.org/\n).\n\n## Security\n\nNote that if your using a `requirement.txt` file the packages will\nbe downloaded with `pip` and it doesn't do any cryptographic\nverification of its downloads.\n\n## Writing application charm\n\nTo create an application subordinate charm that can be related to this charm you need\nat least to define an interface named `directory-path` in your `metadate.yaml` file\nlike this::\n\n  [...]\n  requires:\n    python-django:\n       interface: directory-path\n       scope: container\n       optional: true\n\nWhen you will add a relation between your charm and the python-django charm\nthe hook you will be able to get those relation variables:\n\n- `settings_dir_path`\n- `urls_dir_path`\n- `django_admin_cmd`\n- `install_root`\n\nnow your charm will be informed about where it need to add new settings\nand urls files and how to run additionnal Django commands. \nThe Django charm reload Gunicorn after the relation to catch the changes.\n\n## Changelog\n\n### 3: Notable changes:\n\n- Rewrite the charm using python instead of BASH scripts\n- Django projects now need no modification to work with the charm\n- Use the `django-admin startproject` command with configurable arguments if no repos is specified\n- Juju's generated settings and urls files are now added in a juju_settings and a juju_urls directories by default\n- New MongoDB relation (server side is yet to be done)\n- New upgrade hook that upgrade pip and debian packages\n- Expose ports is now handle by the charm\n\nConfiguration changes:\n\n- default user and group is now ubuntu\n- new install_root option\n- new django_version option\n- new additional_pip_packages option\n- new repos_branch,repos_username,repos_password options\n- new project_name, project_template_extension, project_template_url options\n- new urls_dir_name and settings_dir_name options\n- new project_template_url and project_template_extension options\n- database, uploads, static, secret and cache settings locations are now configurable\n- extra_deb_pkg was renamed additional_distro_packages\n- requirements was renamed requirements_pip_files and now support multiple files\n- if python_path is empty set as install_root\n    \nBackwards incompatible changes:\n\n- swift support was moved to a subordinate charm\n- postgresql relation hook was rename pgsql instead of db\n\n### 2: Notable changes:\n\n- You can configure all wsgi (Gunicorn) settings via the config.yaml file\n- Juju compatible Fabric fabfile.py is included for PAAS commands\n- Swift storage backend is now optional\n\nBackwards incompatible changes:\n\n- Use split settings and urls\n- Permissons are now based on WSGI's user and group instead of just being www-data\n- media and static files are now in new directories ./uploads and ./static/\n- Deprecated configuration variables: site_domain, site_username, site_password, site_admin_email\n\n\n### 1: Notable changes:\n\n- Initial release\n\n## Inspiration\n\n- http://www.deploydjango.com\n- http://lincolnloop.com/django-best-practices/\n- https://github.com/30loops/djangocms-on-30loops.git\n- https://github.com/openshift/django-example\n- http://lincolnloop.com/blog/2013/feb/15/django-settings-parity-youre-doing-it-wrong/\n- http://tech.yipit.com/2011/11/02/django-settings-what-to-do-about-settings-py/\n- http://www.rdegges.com/the-perfect-django-settings-file/\n- https://github.com/xenith/django-base-template.git\n- https://github.com/transifex/transifex/blob/devel/transifex/settings.py\n- http://peterlyons.com/problog/2010/02/environment-variables-considered-harmful\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewsomething%2Fpython-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewsomething%2Fpython-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewsomething%2Fpython-django/lists"}