edc-model


Nameedc-model JSON
Version 0.3.44 PyPI version JSON
download
home_pagehttps://github.com/clinicedc/edc-model
SummaryBase model mixins clinicedc/edc projects
upload_time2024-08-14 15:00:43
maintainerNone
docs_urlNone
authorErik van Widenfelt
requires_python>=3.11
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.11",
    "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/d1/99/26de80a4749f410f4e6d0f4422e91128ba54c8c9e17b15e77c69e499014c/edc_model-0.3.44.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.44",
    "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": "7549765d5c342ee172051960a237501fc683741e8fba10fd1b0389f2d0c0339c",
                "md5": "f4275fda3028ba94241bdeb73bc0bab8",
                "sha256": "3b9c0c88cfd6e3f8e0a0726bef3201733d22b5cc749d5115272dfc729f33fb01"
            },
            "downloads": -1,
            "filename": "edc_model-0.3.44-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4275fda3028ba94241bdeb73bc0bab8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 55159,
            "upload_time": "2024-08-14T15:00:42",
            "upload_time_iso_8601": "2024-08-14T15:00:42.031913Z",
            "url": "https://files.pythonhosted.org/packages/75/49/765d5c342ee172051960a237501fc683741e8fba10fd1b0389f2d0c0339c/edc_model-0.3.44-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d19926de80a4749f410f4e6d0f4422e91128ba54c8c9e17b15e77c69e499014c",
                "md5": "e9ac565027f11304b20a5ccf55082ba9",
                "sha256": "a24a6625bf328f1cbb28318de55dd20ccf537a364c94d00a71c4bec8073e255a"
            },
            "downloads": -1,
            "filename": "edc_model-0.3.44.tar.gz",
            "has_sig": false,
            "md5_digest": "e9ac565027f11304b20a5ccf55082ba9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 51188,
            "upload_time": "2024-08-14T15:00:43",
            "upload_time_iso_8601": "2024-08-14T15:00:43.768693Z",
            "url": "https://files.pythonhosted.org/packages/d1/99/26de80a4749f410f4e6d0f4422e91128ba54c8c9e17b15e77c69e499014c/edc_model-0.3.44.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-14 15:00:43",
    "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: 2.45089s