Package of libraries for Django projects
Project description
For django projects
Classes and functions to create django projects with Bootstrap Css Framework
Installation
Requires Django v2.2+ and Python v3.6+ to run.
Add apps in INSTALLED_APPS:
INSTALLED_APPS = [
...
'for_django_projects.form_utils',
'for_django_projects.pwa'
...
]
Add in settings.py:
SIMBOLO_MONEDA = '$'
URL_GENERAL = 'http://your_domain.com'
CONSTRAINT_MSG = {} #dict of name of constraints as key and error message as value
Classes
CustomValueDb
Inherited from django.db.models.Value
, automatically adds data type in output_field attribute.
NormalModel
Inherited from django.db.models.Model
, adds fields (in all models inheriting from NormalModel) according to the field type.
Example: If there is a field of type BooleanField with the name is_enabled
, then the is_enabled_boolhtml
attribute will be added with a Fontawesome icon named fa-check-circle, otherwise fa-times-circle is added.
Attributes to be added in objects inherited from NormalModel according to field type:
django.db.models.BooleanField:
fieldname_boolhtml
➝ SafeString: Return<i class="fas fas fa-clock text-info"></i>
iffieldname
value isNone
,<i class="fas fa-check-circle text-success"></i>
if isTrue
or<i class="fas fa-times-circle text-secondary"></i>
if isFalse
.fieldname_texthtml ➝ str
: ReturnHABILITADO
iffieldname
value isTrue
, else returnDESHABILITADO
.fieldname_yesorno ➝ str
: ReturnSí
iffieldname
value isTrue
, else returnNo
.
django.db.models.DecimalField:
fieldname_unlocalize ➝ str
: Returns the same value but replacing the comma,
character with dot.
.fieldname_money ➝ str
: Returnfieldname_unlocalize
withsettings.SIMBOLO_MONEDA
, example$10.50
.fieldname_integer ➝ int
: Return thefieldname
value rounded.
django.db.models.FileField:
fieldname_icon
➝ SafeString: Returns Fontawesome icon according to file extension.fieldname_a_tag
➝ SafeString: Returns<a target="_blank" href="URL">{fieldname_icon} descargar</a>
.fieldname_is_image ➝ bool
.fieldname_extension ➝ str
.
ModeloBase
Inherited from NormalModel
, add new fields in model as fecha_registro -> models.DateTimeField
and sin_eliminar -> models.BooleanField
.
License
MIT
Free Software, Hell Yeah!
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
Hashes for for-django-projects-1.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97d95f1cefbd59122635fc7751c0f4fe05a52bd4e2c93124e8b14320a4c69329 |
|
MD5 | 498eb01a6da72162564a8d6f9f3e5aa3 |
|
BLAKE2b-256 | 2d0347bd610343e92bc2819ad7e55682621f5977a9b62064d1da5a00bc1a04c7 |