Field factories for Django models.
Project description
Agape
Field factories for Django models
Synopsis
from django.db.models import Model
from agape import db
class Person( Model ):
first_name = db.string( 32, required=True )
last_name = db.string( 32, required=True )
birthday = db.date( )
email = db.email( )
Description
Shorthand for building Django models.
Fields default to null=True
and blank=True
. Setting required=True
will set both null
and blank
to False
on the native Django field.
Fields
These factory methods are wrappers over the native Django fields. Fields that have required parameters use ordered arguments instead of requiring named arguments. You may pass in any named arguments that the native Django fields accept. Additional arguments may are also provided for specific fields.
boolean( )
color( )
date( )
datetime( )
decimal( max_digits, decimal_places )
duration( )
email( )
file( )
float( )
image( )
integer( )
small_integer( )
join( model, on_delete_policy )
slug( from_field, auto=True )
If the optional auto
paramter is set to True
the slug will
be automatically when the instance is saved for the first time.
string( max_length )
`user( on_delete_policy, auto=True, auto_add=True )
User field which will auto populate on the instance is updated
or created. Set auto=True
to update the field each time the
instance is saved, or auto_add=True
only when the instance
is saved for the first time.
You must add the agape.db.middleware.AgapeUserMiddleware
to
your settings.py
file to use auto
and auto_add
.
License
Copyright (C) 2021 Maverik Minett
The (MIT) license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file agape-db-0.0.1.tar.gz
.
File metadata
- Download URL: agape-db-0.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 568c86ec97838fd219d4f71ab82d0b0ac30775f47d5199792314e86790ff8bef |
|
MD5 | 949a810d4e3d6d37f08f7fb31ba2c76e |
|
BLAKE2b-256 | 1eddac575fe07ddd61da3beee77281c0c4d8153d63456cf323dd4b513ce22139 |