Skip to main content

A reusable Django app to load data from Grist to Django models

Project description

django-grist-loader

Django reusable app to load data from Grist into read-only Django models.

Installation

The usual way:

  1. Install

    uv add django-grist-loader
    
  2. Configure

    Django's settings:

    INSTALLED_APPS = (
        ...,
        "grist_loader",
        ...,
    )
    
    GRIST_PYGRISTER_CONFIG = {
        "GRIST_API_KEY": os.environ.get("GRIST_API_KEY", ""),
        "GRIST_SELF_MANAGED": "Y",
        "GRIST_SELF_MANAGED_HOME": f"{os.environ.get('GRIST_PROTOCOL', 'https://')}{os.environ.get('GRIST_HOST', '')}",
        "GRIST_SELF_MANAGED_SINGLE_ORG": "N",
        "GRIST_SERVER_PROTOCOL": os.environ.get("GRIST_PROTOCOL", "https://"),
        "GRIST_API_SERVER": os.environ.get("GRIST_HOST", ""),
        "GRIST_API_ROOT": os.environ.get("GRIST_API_ROOT", "api"),
        "GRIST_TEAM_SITE": os.environ.get("GRIST_API_DOCS", "docs"),
        "GRIST_WORKSPACE_ID": os.environ.get("GRIST_WORKSPACE_ID", ""),
        "GRIST_DOC_ID": os.environ.get("GRIST_DOC_ID", ""),
        "GRIST_RAISE_ERROR": "Y",
        "GRIST_SAFEMODE": "N",
    } 
    
  3. Define the required envvars that make sense to your project

Usage

  1. Define a Django model that subclasses GristModel:

    from django.db import models
    from grist_loader.models import GristModel
    
    
    class MyModel(GristModel):
       my_char_field = models.CharField(max_length=100)
       my_int_field = models.IntegerField()
       my_date_field = models.DateField()
    
  2. Within a grist.py module, define a loader class that subclasses GristLoader:

    from django.conf import settings
    from grist_loader.loader import GristLoader, register_grist_loader
    
    from .models import MyModel
    
    
    @register_grist_loader
    class MyLoader(GristLoader):
       model = MyModel
       pygrister_config = settings.GRIST_PYGRISTER_CONFIG
       table = "MyGristTableName"
       required_cols = ("MyChar",)
       fields = {
         "MyChar": MyModel.my_char_field,
         "MyInt": MyModel.my_int_field,
         "MyDate": MyModel.my_date_field,
       }
       filter = {
           "MyChar": ["some value"],
       }
    
  3. Load your data

    python manage.py grist_load_all
    
  4. Profit!

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_grist_loader-0.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_grist_loader-0.3.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django_grist_loader-0.3.0.tar.gz.

File metadata

  • Download URL: django_grist_loader-0.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_grist_loader-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9c7b694c00a6c2128a9e2fd33597b5de063633dfa1f3409403f98f760d8547c2
MD5 0050e2a2f2e0f4856d71b44208e8097e
BLAKE2b-256 fc5bf54cf7e7943c1c45298a433b14c479e8f49b8a1588966b54f769f58ca866

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grist_loader-0.3.0.tar.gz:

Publisher: main.yml on David-Guillot/django-grist-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_grist_loader-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_grist_loader-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5892e85181c5f9e84763c92d1e5843d06d425c6046ca6ba30fcbcd4fd9bdfe2d
MD5 c488dbaf4ad5e50bf5a79ffb787d1687
BLAKE2b-256 3cbef4545c9927caf4e223f511c6497e3df8dc487b0519ec1d4742bf986696f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_grist_loader-0.3.0-py3-none-any.whl:

Publisher: main.yml on David-Guillot/django-grist-loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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