Skip to main content

Models Manager

Project description

Models Manager

Library for creating object models and for interacting with the database. Provides simple interface for that. For databases only PostgreSQL supported from the box.

For databases enabled support for multiple connections

Simple example:

from models_manager.manager.field import Field
from models_manager.manager.model import Model


class User(Model):
    email = Field(default='some@gmail.com', json='email', max_length=255)
    username = Field(default='some', json='username', null=True, max_length=255)
    password = Field(default='other', json='password', max_length=255)


json = User.manager.to_json
print(json)

json_negative = User.manager.to_negative_json()
print(json_negative)

user_schema = User.manager.to_schema
print(user_schema)

user_array_schema = User.manager.to_array_schema
print(user_array_schema)  

Working with databases:

To work with database, we have to define settings. So, somewhere in your settings.py:

import models_manager.settings

models_manager.settings.DATABASE = {
    'host': 'some',
    'port': 5432,
    'user': 'user',
    'password': 'password',
}

models_manager.settings.DATABASES = ['some', 'other', 'another']
models_manager.settings.DATABASE_LOGGING = True

Then in your model you have to override database and identity attributes

from models_manager.manager.field import Field
from models_manager.manager.model import Model


class User(Model):
    database = 'some'
    identity = 'id'
    
    id = Field(default=1, json='id', category=int)
    email = Field(default='some@gmail.com', json='email', max_length=255)
    username = Field(default='some', json='username', null=True, max_length=255)
    password = Field(default='other', json='password', max_length=255)

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

models_manager-0.6.1.tar.gz (18.7 kB view details)

Uploaded Source

File details

Details for the file models_manager-0.6.1.tar.gz.

File metadata

  • Download URL: models_manager-0.6.1.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.8.2 requests/2.27.1 setuptools/60.10.0 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.8.2

File hashes

Hashes for models_manager-0.6.1.tar.gz
Algorithm Hash digest
SHA256 920d40df3d048a28db2331cf2d335614174962c4e0ce76c257f84c51d5de0d99
MD5 0ff7bf7b7dc27c1bf56b36b210d07d0f
BLAKE2b-256 e8e0e984ab9c9f80ab4bc67ecfa5c67ac7d495b5682ac88c90c89a63bc2062b5

See more details on using hashes here.

Supported by

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