{"id":13416095,"url":"https://github.com/bennylope/django-organizations","last_synced_at":"2025-05-13T19:14:07.136Z","repository":{"id":2367180,"uuid":"3331322","full_name":"bennylope/django-organizations","owner":"bennylope","description":":couple: Multi-user accounts for Django projects","archived":false,"fork":false,"pushed_at":"2024-10-30T18:35:14.000Z","size":1023,"stargazers_count":1316,"open_issues_count":14,"forks_count":214,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-06T20:50:59.126Z","etag":null,"topics":["accounts","django","groups","multi-tenant","organisation","organization","python"],"latest_commit_sha":null,"homepage":"http://django-organizations.readthedocs.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bennylope.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","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":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-02-02T02:38:49.000Z","updated_at":"2025-05-02T07:31:15.000Z","dependencies_parsed_at":"2023-12-20T10:23:20.394Z","dependency_job_id":"ed6c0dc0-fa2a-44cd-b947-792204fb3e2d","html_url":"https://github.com/bennylope/django-organizations","commit_stats":{"total_commits":649,"total_committers":53,"mean_commits":"12.245283018867925","dds":0.5377503852080123,"last_synced_commit":"b1110a23511e2fcdb09d91bd49abcb1100576adc"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennylope%2Fdjango-organizations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennylope%2Fdjango-organizations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennylope%2Fdjango-organizations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennylope%2Fdjango-organizations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bennylope","download_url":"https://codeload.github.com/bennylope/django-organizations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010813,"owners_count":21998995,"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":["accounts","django","groups","multi-tenant","organisation","organization","python"],"created_at":"2024-07-30T21:00:54.258Z","updated_at":"2025-05-13T19:14:07.117Z","avatar_url":"https://github.com/bennylope.png","language":"Python","funding_links":[],"categories":["Third-Party Packages","Authentication","认证","Django Utilities","Python"],"sub_categories":["Users"],"readme":"====================\ndjango-organizations\n====================\n\n.. start-table\n\n.. list-table::\n    :stub-columns: 1\n\n    * - Summary\n      - Groups and multi-user account management\n    * - Author\n      - Ben Lopatin (https://www.benlopatin.com)\n    * - Status\n      - |docs| |version| |wheel| |supported-versions| |supported-implementations|\n\n.. |docs| image:: https://readthedocs.org/projects/django-organizations/badge/?style=flat\n    :target: https://readthedocs.org/projects/django-organizations\n    :alt: Documentation Status\n\n.. |version| image:: https://img.shields.io/pypi/v/django-organizations.svg?style=flat\n    :alt: PyPI Package latest release\n    :target: https://pypi.python.org/pypi/django-organizations\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/django-organizations.svg?style=flat\n    :alt: PyPI Wheel\n    :target: https://pypi.python.org/pypi/django-organizations\n\n.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/django-organizations.svg?style=flat\n    :alt: Supported versions\n    :target: https://pypi.python.org/pypi/django-organizations\n\n.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/django-organizations.svg?style=flat\n    :alt: Supported implementations\n    :target: https://pypi.python.org/pypi/django-organizations\n\n\n.. end-table\n\n\nSeparate individual **user identity** from **accounts, subscriptions, etc.**.\nDjango Organizations adds user-managed, multi-user groups to your Django project.\nUse Django Organizations whether your site needs organizations that function like\nsocial groups or multi-user account objects to provide account and subscription\nfunctionality beyond the individual user.\n\n* Works with your existing user model, whether\n  `django.contrib.auth` or a custom model. No additional user\n  or authentication functionality required.\n* Users can be belong to and own more than one organization (account, group)\n* Invitation and registration functionality works out of the box for many\n  situations and can be extended as need to fit specific requirements.\n* Start with the base models or use your own for greater customization.\n\nDocumentation is on `Read the Docs\n\u003chttp://django-organizations.readthedocs.org/en/latest/index.html\u003e`_\n\nProject goals\n=============\n\ndjango-organizations should be backend agnostic:\n\n1. Authentication agnostic\n2. Registration agnostic\n3. Invitation agnostic\n4. User messaging agnostic\n\nEtc.\n\nDevelopment \u0026 Contributing\n==========================\n\nThe basic functionality should not need much extending. Current dev priorities\nfor me and contributors should include:\n\n* Improving the tests and test coverage (ideally moving them back out of the\n  main module and executable using the setup.py file)\n* Improving the backends and backends concept so that additional invitation and\n  registration backends can be used\n* Documentation\n* Ensuring all application text is translatable\n\nPlease use the project's issues tracker to report bugs, doc updates, or other\nrequests/suggestions.\n\nTargets \u0026 testing\n-----------------\n\nThe codebase is targeted and tested against:\n\n* Django 3.2.x against Python 3.8, 3.9, 3.10\n* Django 4.2.x against Python 3.8, 3.9, 3.10, 3.11, 3.12\n* Django 5.1.x against Python 3.10, 3.11, 3.12\n\nTo run the tests against all target environments, install `tox\n\u003chttps://testrun.org/tox/latest/\u003e`_ and then execute the command::\n\n    tox\n\nFast testing\n------------\n\nTesting each change on all the environments takes some time, you may\nwant to test faster and avoid slowing down development by using pytest\nagainst your current environment::\n\n    pip install .[tests]\n    pytest\n\nSupply the ``-x`` option for **failfast** mode::\n\n    pytest -x\n\nSubmitting\n----------\n\nThese submission guidelines will make it more likely your submissions will be\nreviewed and make it into the project:\n\n* Ensure they match the project goals and are sufficiently generalized\n* Please try to follow `Django coding style\n  \u003chttps://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/\u003e`_.\n  The code base style isn't all up to par, but I'd like it to move in that\n  direction\n* Also please try to include `good commit log messages\n  \u003chttp://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html\u003e`_.\n* Pull requests should include an amount of code and commits that are\n  reasonable to review, are **logically grouped**, and based off clean feature\n  branches.\n\nCode contributions are expected to pass in all target environments, and\npull requests should be made from branches with passing builds on `GitHub Actions \u003chttps://github.com/bennylope/django-organizations/actions/workflows/test.yml\u003e`_.\n\nInstalling\n==========\n\nFirst add the application to your Python path. The easiest way is to use\n`pip`::\n\n    pip install django-organizations\n\nCheck the `Release History tab \u003chttps://pypi.org/project/django-organizations/#history\u003e`_ on\nthe PyPI package page for pre-release versions. These can be downloaded by specifying the version.\n\nBy default you will need to install `django-extensions` or comparable libraries\nif you plan on adding Django Organizations as an installed app to your Django\nproject. See below on configuring.\n\nConfiguring\n-----------\n\nThe simplest way to get *started* using Django Organizations is to install the\napp and use the \"concrete\" models.\n\nMake sure you have `django.contrib.auth` installed, and add the `organizations`\napplication to your `INSTALLED_APPS` list:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        'django.contrib.auth',\n        'organizations',\n    )\n\nThen update your project URLs config. You should hook in the\nmain application URL conf as well as your chosen invitation backend URLs:\n\n.. code-block:: python\n\n    from organizations.backends import invitation_backend\n\n    urlpatterns = [\n        ...\n        path('accounts/', include('organizations.urls')),\n        path('invitations/', include(invitation_backend().get_urls())),\n    ]\n\nThis is the simplest way of using the library, but it's far from the only\nor even the best way. See the `Cooking with Django Organizations` section\nof the docs full explanation of the use cases and how to configure them.\n\nAuto slug field\n~~~~~~~~~~~~~~~\n\nThe standard way of using Django Organizations is to use it as an installed app\nin your Django project. Django Organizations will need to use an auto slug\nfield which are not included. By default it will try to import these from\ndjango-extensions, but you can configure your own in settings. The default:\n\n.. code-block:: python\n\n    ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField'\n\nAlternative:\n\n.. code-block:: python\n\n    ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField'\n\n- `django-extensions \u003chttp://django-extensions.readthedocs.org/en/latest/\u003e`_\n- `Django AutoSlug \u003chttps://github.com/justinmayer/django-autoslug/\u003e`_\n- `django-slugger \u003chttps://gitlab.com/dspechnikov/django-slugger/\u003e`_\n\nRegistration \u0026 invitation backends\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can specify a different invitation backend in your project settings, and\nthe `invitation_backend` function will provide the URLs defined by that\nbackend:\n\n.. code-block:: python\n\n    INVITATION_BACKEND = 'myapp.backends.MyInvitationBackend'\n\n\nUsage Overview\n==============\n\nFor most use cases it should be sufficient to include the app views directly\nusing the default URL conf file. You can customize their functionality or\naccess controls by extending the base views.\n\nThere are three models:\n\n* **Organization** The group object. This is what you would associate your own\n  app's functionality with, e.g. subscriptions, repositories, projects, etc.\n* **OrganizationUser** A custom `through` model for the ManyToMany relationship\n  between the `Organization` model and the `User` model. It stores additional\n  information about the user specific to the organization and provides a\n  convenient link for organization ownership.\n* **OrganizationOwner** The user with rights over the life and death of the\n  organization. This is a one to one relationship with the `OrganizationUser`\n  model. This allows `User` objects to own multiple organizations and makes it\n  easy to enforce ownership from within the organization's membership.\n\nThe underlying organizations API is simple:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from organizations.utils import create_organization\n    \u003e\u003e\u003e chris = User.objects.get(username=\"chris\")\n    \u003e\u003e\u003e soundgarden = create_organization(chris, \"Soundgarden\", org_user_defaults={'is_admin': True})\n    \u003e\u003e\u003e soundgarden.is_member(chris)\n    True\n    \u003e\u003e\u003e soundgarden.is_admin(chris)\n    True\n    \u003e\u003e\u003e soundgarden.owner.organization_user\n    \u003cOrganizationUser: Chris Cornell\u003e\n    \u003e\u003e\u003e soundgarden.owner.organization_user.user\n    \u003e\u003e\u003e \u003cUser: chris\u003e\n    \u003e\u003e\u003e audioslave = create_organization(chris, \"Audioslave\")\n    \u003e\u003e\u003e tom = User.objects.get(username=\"tom\")\n    \u003e\u003e\u003e audioslave.add_user(tom, is_admin=True)\n    \u003cOrganizationUser: Tom Morello\u003e\n\nCustom models\n-------------\n\nDjango-organizations can act as a base library (not installed in your project)\nand used to create unique organization model sets using custom tables. See the\n`Cooking with Django Organizations\n\u003chttp://django-organizations.readthedocs.org/en/latest/cookbook.html#advanced-customization\u003e`_\nsection in the documentation for advice on proceeding.\n\nLicense\n=======\n\nAnyone is free to use or modify this software under the terms of the BSD\nlicense.\n\nSponsors\n========\n\n`Muster \u003chttps://www.muster.com/home?utm_source=github\u0026campaign=opensource\u003e`_ is building precision advocacy software to impact policy through grassroots action.\n\n.. image:: https://www.muster.com/hs-fs/hubfs/muster_logo-2.png?width=600\u0026name=muster_logo-2.png\n  :target: https://www.muster.com/home?utm_source=github\u0026campaign=opensource\n  :width: 400\n  :alt: Alternative text\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennylope%2Fdjango-organizations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennylope%2Fdjango-organizations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennylope%2Fdjango-organizations/lists"}