edc-model


Nameedc-model JSON
Version 0.3.46 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-model
SummaryBase model mixins clinicedc/edc projects
upload_time2024-11-20 22:40:17
maintainerNone
docs_urlNone
authorErik van Widenfelt
requires_python>=3.12
licenseGPL license, see LICENSE
keywords django django base models fields forms admin clinicedc clinical trials
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            |pypi| |actions| |codecov| |downloads| |pyup|

edc-model
---------

Base model, manager, field, form and admin classes for Edc.



All models in the Edc use ``BaseUuidModel``

.. code-block:: python

    from edc_model.model_mixins import BaseUuidModel

    class MyModel(BaseUuidModel):

        ....

The mixin:

* sets the id fields to a ``UUIDField`` instead of an integer;
* adds audit fields through ``BaseModel`` (user_created, user_modified, date_created, etc);
* adds ``UrlModelMixin``, ``DeviceModelMixin``

Most models require an audit trail. If so, add the ``HistoricalRecord`` model manager.

.. code-block:: python

    from edc_model.model.models import HistoricalRecord

    class MyModel(BaseUuidModel):

        ...
        history = HistoricalRecord()


``HistoricalRecord`` is an almost identical version of ``simple_history.models.HistoricalRecord``
with the exception of two methods:  ``get_extra_fields()`` and ``add_extra_methods()``. Method
``get_extra_fields()`` is overridden to change the ``history_id`` primary key from an
``IntegerField`` to a ``UUIDField`` so that it can work with module ``django_collect_offline``.


The audit trail models created by ``HistoricalRecord`` have a foreign key to ``auth.User``. In order for the models to work with `django_collect_offline` specify the django_collect_offline User model in settings:

.. code-block:: python

    AUTH_USER_MODEL = 'django_collect_offline.User'


Notes
-----

User created and modified fields behave as follows:

* created is only set on pre-save add
* modified is always updated


.. |pypi| image:: https://img.shields.io/pypi/v/edc-model.svg
    :target: https://pypi.python.org/pypi/edc-model

.. |actions| image:: https://github.com/clinicedc/edc-model/actions/workflows/build.yml/badge.svg
  :target: https://github.com/clinicedc/edc-model/actions/workflows/build.yml

.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-model/branch/develop/graph/badge.svg
    :target: https://codecov.io/gh/clinicedc/edc-model

.. |downloads| image:: https://pepy.tech/badge/edc-model
    :target: https://pepy.tech/project/edc-model

.. |pyup| image:: https://pyup.io/repos/github/clinicedc/edc-model/shield.svg
    :target: https://pyup.io/repos/github/clinicedc/edc-model/
    :alt: Updates

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clinicedc/edc-model",
    "name": "edc-model",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "django django base models fields forms admin, clinicedc, clinical trials",
    "author": "Erik van Widenfelt",
    "author_email": "ew2789@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/71/c0/f6ea2c58597552d0e4149fd47dc099362bd17b565d8528cd8d13c43add64/edc_model-0.3.46.tar.gz",
    "platform": null,
    "description": "|pypi| |actions| |codecov| |downloads| |pyup|\n\nedc-model\n---------\n\nBase model, manager, field, form and admin classes for Edc.\n\n\n\nAll models in the Edc use ``BaseUuidModel``\n\n.. code-block:: python\n\n    from edc_model.model_mixins import BaseUuidModel\n\n    class MyModel(BaseUuidModel):\n\n        ....\n\nThe mixin:\n\n* sets the id fields to a ``UUIDField`` instead of an integer;\n* adds audit fields through ``BaseModel`` (user_created, user_modified, date_created, etc);\n* adds ``UrlModelMixin``, ``DeviceModelMixin``\n\nMost models require an audit trail. If so, add the ``HistoricalRecord`` model manager.\n\n.. code-block:: python\n\n    from edc_model.model.models import HistoricalRecord\n\n    class MyModel(BaseUuidModel):\n\n        ...\n        history = HistoricalRecord()\n\n\n``HistoricalRecord`` is an almost identical version of ``simple_history.models.HistoricalRecord``\nwith the exception of two methods:  ``get_extra_fields()`` and ``add_extra_methods()``. Method\n``get_extra_fields()`` is overridden to change the ``history_id`` primary key from an\n``IntegerField`` to a ``UUIDField`` so that it can work with module ``django_collect_offline``.\n\n\nThe audit trail models created by ``HistoricalRecord`` have a foreign key to ``auth.User``. In order for the models to work with `django_collect_offline` specify the django_collect_offline User model in settings:\n\n.. code-block:: python\n\n    AUTH_USER_MODEL = 'django_collect_offline.User'\n\n\nNotes\n-----\n\nUser created and modified fields behave as follows:\n\n* created is only set on pre-save add\n* modified is always updated\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/edc-model.svg\n    :target: https://pypi.python.org/pypi/edc-model\n\n.. |actions| image:: https://github.com/clinicedc/edc-model/actions/workflows/build.yml/badge.svg\n  :target: https://github.com/clinicedc/edc-model/actions/workflows/build.yml\n\n.. |codecov| image:: https://codecov.io/gh/clinicedc/edc-model/branch/develop/graph/badge.svg\n    :target: https://codecov.io/gh/clinicedc/edc-model\n\n.. |downloads| image:: https://pepy.tech/badge/edc-model\n    :target: https://pepy.tech/project/edc-model\n\n.. |pyup| image:: https://pyup.io/repos/github/clinicedc/edc-model/shield.svg\n    :target: https://pyup.io/repos/github/clinicedc/edc-model/\n    :alt: Updates\n",
    "bugtrack_url": null,
    "license": "GPL license, see LICENSE",
    "summary": "Base model mixins clinicedc/edc projects",
    "version": "0.3.46",
    "project_urls": {
        "Homepage": "https://github.com/clinicedc/edc-model"
    },
    "split_keywords": [
        "django django base models fields forms admin",
        " clinicedc",
        " clinical trials"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "60933e606d3dcf0e99f99f2b3fd705e205b3158c58929f437d2d7836a1830733",
                "md5": "003fdcbfecfce506c4cb43f67d15865f",
                "sha256": "eb7d363245c5307f37e5c8c7d0c416facaf9b33ace2e40bfbbe777ab67e1dd44"
            },
            "downloads": -1,
            "filename": "edc_model-0.3.46-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "003fdcbfecfce506c4cb43f67d15865f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 55893,
            "upload_time": "2024-11-20T22:40:15",
            "upload_time_iso_8601": "2024-11-20T22:40:15.803660Z",
            "url": "https://files.pythonhosted.org/packages/60/93/3e606d3dcf0e99f99f2b3fd705e205b3158c58929f437d2d7836a1830733/edc_model-0.3.46-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71c0f6ea2c58597552d0e4149fd47dc099362bd17b565d8528cd8d13c43add64",
                "md5": "b0fd1e99852e5456803db09a3080ad6f",
                "sha256": "73f88623ca8243b35a1c64c1ba4f64d17edcbe975f06e436319ed9c5af1cf21b"
            },
            "downloads": -1,
            "filename": "edc_model-0.3.46.tar.gz",
            "has_sig": false,
            "md5_digest": "b0fd1e99852e5456803db09a3080ad6f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 51554,
            "upload_time": "2024-11-20T22:40:17",
            "upload_time_iso_8601": "2024-11-20T22:40:17.171095Z",
            "url": "https://files.pythonhosted.org/packages/71/c0/f6ea2c58597552d0e4149fd47dc099362bd17b565d8528cd8d13c43add64/edc_model-0.3.46.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 22:40:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clinicedc",
    "github_project": "edc-model",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "edc-model"
}
        
Elapsed time: 1.62162s