Skip to main content

Reusable functionality

Project description

About

A reusable DRF library that provides reusable components.

Installation

pip install django-pycorpkit

Quick start

  1. Add “django-pycorpkit” to your INSTALLED_APPS setting:

    INSTALLED_APPS = [
        ...
        "pycorpkit.common",
        "pycorpkit.accountx",
        "pycorpkit.org_structure",
    ]
  2. Include the django_sample_lib URLconf in your project urls.py:

    path('api/', include('pycorpkit.urls')),
  3. Run migrations:

    python manage.py migrate
  4. Add exception handler and default backend filter:

    REST_FRAMEWORK = {
        "EXCEPTION_HANDLER": "pycorpkit.common.utils.exception_handler.custom_exception_handler",
        "DEFAULT_PERMISSION_CLASSES": [
            "pycorpkit.accountx.permissions.enforce.EnforceDRFViewPermission",
        ],
        "DEFAULT_FILTER_BACKENDS": (
            "pycorpkit.common.filters.base.OrganisationFilterBackend",
        ),
    }
  5. Add variables:

    PERMISSIONS_PATH = "testapp.perms"
    PERMISSIONS_GROUPS_PATH = "testapp.perms.apps.perm_groups"
    APP_NAME = "PyCorpKit"
    AUTH_USER_MODEL = "accountx.User"
    SIMPLE_JWT = {
        "ACCESS_TOKEN_LIFETIME": timedelta(seconds=3600),
        "REFRESH_TOKEN_LIFETIME": timedelta(days=7),
    }
    DEFAULT_FROM_EMAIL = "admin@example.com"

Development

To set up the development environment:

  1. Clone the repository

  2. Create a virtual environment and activate it

  3. Install development dependencies:

    pip install -e ".[dev]"
  4. Run tests:

    python -m pytest tests
    # OR
    pytest tests/

Install test dependencies

pip install -e ".[test]"

Making migrations

python testapp/manage.py makemigrations
python testapp/manage.py makemigrations <app_name> --empty

Migrate

python testapp/manage.py migrate

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

django_pycorpkit-1.0.0.tar.gz (69.1 kB view details)

Uploaded Source

Built Distribution

django_pycorpkit-1.0.0-py2.py3-none-any.whl (66.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django_pycorpkit-1.0.0.tar.gz.

File metadata

  • Download URL: django_pycorpkit-1.0.0.tar.gz
  • Upload date:
  • Size: 69.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for django_pycorpkit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 68c5361e36863d434e7a6d6d96599c69649567252a24490b2e27f9b94eaeaf28
MD5 131484d529fd55799f106c863d92a931
BLAKE2b-256 4f5c4971e9401df85aff0212fa3dac740182cff6703cec63d4b0af461e66c792

See more details on using hashes here.

File details

Details for the file django_pycorpkit-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_pycorpkit-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a13df4dc55f96cb2a56e50dfd7e7dac75bd3d27d4b5db8af02ccc38c9c8f180a
MD5 7d615adbfc4e3723ef0cd050fe7367b9
BLAKE2b-256 ff120c8d19e7d5ceff1160fc92bfbc9d9c98e9546ed9af21a3beec29da0e7fab

See more details on using hashes here.

Supported by

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