Skip to main content

varorm - variables orm with django admin support

v0.1 - Basic models and Django admin support

v0.1.1 - Add groups access to variables and verbose_name for django admin, setup key on init of model

v0.1.2 - Add MongoStorage

v0.1.4 - New storage in django model

v0.1.5 - Fixed datetime and date fields, added init_load param and update method

v0.1.6 - Bug fix

v0.1.7 - Bug fix, refactoring of widgets

TODO - refactor django widgets, better type-hints

Documentation

from varorm.models import Model
from varorm import fields
from varorm.storage import JsonStorage
from varorm.exceptions import VarDoesNotExistException

storage = JsonStorage(path="test.json")

class TestModel(Model):
    a = fields.IntegerField(default=1)
    b = fields.CharField(null=True)
    c = fields.FloatField()

    class Meta: # optional
        key = 'test' # key in storage for current model


TestModel.connect(storage)

print(TestModel().a) # >> 1
print(TestModel().b) # >> None
print(TestModel().c) # >> VarDoesNotExistException

TestModel().a = 5
print(TestModel().a) # >> 5

# Also u can change key in time of using model:
print(TestModel(key='test2').a) # >> 1

storage.save() # for file base storages

Django-Documentation

variables.py in your app(the same where models.py)

from varorm.models import Model
from varorm import fields

class TestModel(Model):
    a = fields.IntegerField(default=1)
    b = fields.CharField(null=True)
    c = fields.FloatField(verbose_name="Test C")

    class Meta: # optional
        key = 'test' # key in storage for current model
        groups = ['TestGroups'] # groups who have access to this model, __all__ for access to everyone
        verbose_name = 'TestNameOfModel' # the name of model in django admin

settings.py

INSTALLED_APPS = [
    ...
    "varorm.dj",
    ...
]
VARORM_STORAGE = 'varorm.storage.RedisStorage' # import path to storage
VARORM_STORAGE_CONFIG = {
    "url": "redis://localhost:6379/3"
} # storage init config

Now in your django admin you will find VARORM app, enjoy!

Important: when you use FileStorage(JsonStorage or PickleStorage) put {"save_on_set": True} in VARORM_STORAGE_CONFIG

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

varorm-0.1.10.tar.gz (18.7 kB view details)

Uploaded Source

File details

Details for the file varorm-0.1.10.tar.gz.

File metadata

  • Download URL: varorm-0.1.10.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.12

File hashes

Hashes for varorm-0.1.10.tar.gz
Algorithm Hash digest
SHA256 f363910d34cd7a9b699ad514e0e25076f8c6882db296254e6070780de91ec463
MD5 449cded58ff9d9d8bc75a59cb5fd6607
BLAKE2b-256 10fd1e4e6879a948ba1bddaebb105967189f0159369c0f9fd1925f3d8e663902

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.10 This release

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

0.0.1

1 file

Supported by

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