- Notifications
You must be signed in to change notification settings - Fork4
Extra Fields for Peewee 3 on Python 3.
License
juancarlospaco/peewee-extra-fields
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Extra additional Fields forPeewee ORM.
Autogeneration of HTML5 Widgets for Fields. Postgresql & Peewee 3 Support. Fields for several countries.
We want to be a hub for all custom Fields.If your created a Custom Peewee Field feel free toSend Pull Requests!!!.Open Repo access to anyone who want to contribute, just contact me.
peewee_extra_fields.PositiveSmallIntegerField()
peewee_extra_fields.PositiveIntegerField()
peewee_extra_fields.PositiveBigIntegerField()
Description:IntegerField
subclass but only acceptsPositive values (>= 0).
PositiveSmallIntegerField
accepts positive integers from0
to32_767
according tothe Standard SQL Oficial Specs.
PositiveIntegerField
accepts positive integers from0
to2_147_483_647
according tothe Standard SQL Oficial Specs.
PositiveBigIntegerField
accepts positive integers from0
to9_223_372_036_854_775_807
according tothe Standard SQL Oficial Specs.
The smaller integer field type you can use, the faster performance, by definition.
Arguments: None (should take the same*args
and**kwargs
asIntegerField
)
Keyword Arguments: None (should take the same*args
and**kwargs
asIntegerField
).
Returns:int
.
Base Class:IntegerField
,SmallIntegerField
,BigIntegerField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPositiveIntegerField# its the same with PositiveSmallIntegerField and PositiveBigIntegerField>>>PositiveIntegerField().db_value(1)1>>>PositiveIntegerField().db_value(0)0>>>PositiveIntegerField().db_value(-1)Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PositiveIntegerFieldValueisnotaPositiveInteger (validvaluesmustbeIntegers>=0):-1.
peewee_extra_fields.PositiveFloatField(round_by: int=None)
Description:FloatField
subclass but only acceptsPositive values (>= 0).Optionally it can round Floats using Pythonsround()
withround_by
integer argument.
PositiveFloatField
from0
to6
decimal digits precision according tothe Standard SQL Oficial Specs.
Arguments:
round()
roundfloat
using Pythonsround()
, optional, defaults toNone
, integer type, positive value.
Keyword Arguments: None (should take the same*args
and**kwargs
asFloatField
).
Returns:float
.
Base Class:FloatField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPositiveFloatField>>>PositiveFloatField().db_value(1.0)1.0>>>PositiveFloatField().db_value(0.0)0.0>>>PositiveFloatField().db_value(-1.0)Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PositiveFloatFieldValueisnotaPositiveFloat (validvaluesmustbeFloats>=0):-1.0.>>>PositiveFloatField(round_by=2).db_value(1.123456789)1.12>>>PositiveFloatField(round_by=4).db_value(1.123456789)1.1235>>>PositiveFloatField(round_by=-2).db_value(1.123456789)Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PositiveFloatField'round_by'argumentisnotaNon-ZeroPositiveIntegernumber (validvaluesmustbeIntegers>0):-2.
peewee_extra_fields.PositiveDecimalField(round_by: int=None)
Description:DecimalField
subclass but only acceptsPositive values (>= 0).
PositiveDecimalField
from0
to131_072
decimal digits precision before the decimal point and from0
to16_383
decimal digits precision after the decimal point according tothe Standard SQL Oficial Specs.
up to 131072 digits before the decimal point; up to 16383 digits after the decimal pointArguments:
round()
rounddecimal.Decimal
using PythonsDecimal().quantize().normalize()
, optional, defaults toNone
, integer type, positive value.
Keyword Arguments: None (should take the same*args
and**kwargs
asDecimalField
).
Returns:decimal.Decimal
.
Base Class:DecimalField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPositiveDecimalField>>>fromdecimalimportDecimal>>>PositiveDecimalField().db_value(Decimal("1.0"))Decimal('1.0')>>>PositiveDecimalField().db_value(Decimal("0.0"))Decimal('0.0')>>>PositiveDecimalField().db_value(Decimal("-1.0"))Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PositiveDecimalFieldValueisnotaPositiveDecimal (validvaluesmustbeDecimals>=0):-1.0.>>>PositiveDecimalField(round_by=2).db_value(Decimal("1.123456789"))Decimal('1.12')>>>PositiveDecimalField(round_by=4).db_value(Decimal("1.123456789"))Decimal('1.1235')>>>PositiveDecimalField(round_by=-2).db_value(Decimal("1.123456789"))Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PositiveDecimalField'round_by'argumentisnotaNon-ZeroPositiveIntegernumbers (validvaluesmustbeIntegers>0):-2.
peewee_extra_fields.IPAddressField()
Description:BigIntegerField
subclass but only acceptsIP Addresses values (IPv4 & IPv6).IPAddressField uses BigIntegerField for maximum performance.Difference with PeeweeIPField
is that it supports IPv6, is a little bit faster,can do checking whether or not two hosts are on the same subnet,iterating over all hosts in a particular subnet,checking whether or not a string represents a valid IP address or network definition, etc etc.Difference between Peewee IPField and this IPAddressField.
Arguments: None (should take the same*args
and**kwargs
asBigIntegerField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asBigIntegerField
).
Returns:IPv4Address
orIPv6Address
.
Base Class:BigIntegerField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportIPAddressField>>>IPAddressField().db_value("127.0.0.1")2130706433>>>IPAddressField().db_value("fe80::12c3:7bff:fe92:9d4c")338288524927261089655370957493906873676>>>IPAddressField().python_value(338288524927261089655370957493906873676)IPv6Address('fe80::12c3:7bff:fe92:9d4c')>>>IPAddressField().db_value("10.0.256")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IPAddressFieldValuestringisnotaValidIPv4orv6Address (validvaluesmustbeavalid<class'ipaddress.IPv4Address'>):10.0.256-->'10.0.256'doesnotappeartobeanIPv4orIPv6address.>>>IPAddressField().db_value("a.b.c")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IPAddressFieldValuestringisnotaValidIPv4orv6Address (validvaluesmustbeavalid<class'ipaddress.IPv4Address'>):a.b.c-->'a.b.c'doesnotappeartobeanIPv4orIPv6address.
peewee_extra_fields.IPNetworkField()
Description:CharField
subclass but only acceptsIP Networks values (IPv4 & IPv6).
Arguments: None (should take the same*args
and**kwargs
asCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:IPv4Network
orIPv6Network
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportIPNetworkField>>>IPNetworkField().db_value("10.0.0.0")'10.0.0.0'>>>IPNetworkField().db_value("10.0.0.0/23")'10.0.0.0/23'>>>IPNetworkField().db_value("256.0.0.0/23")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IPNetworkFieldValuestringisnotaValidIPv4orv6Network (validvaluesmustbeavalid<class'ipaddress.IPv4Network'>):256.0.0.0/23-->'256.0.0.0/23'doesnotappeartobeanIPv4orIPv6network.>>>IPNetworkField().python_value("10.0.0.0/23")IPv4Network('10.0.0.0/23')
peewee_extra_fields.PastDateField()
Description:DateField
subclass but only accepts datesNot on the Future values.Past is Ok, Present is Ok, Future is Not Ok.Most of times you need Dates on the Past, eg. your Birthday cant be in the Future.
This Field has an additional helper method for lazy devs:peewee_extra_fields.PastDateField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asIntegerField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asIntegerField
).
Returns:date
.
Base Class:DateField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPastDateField>>>fromdatetimeimportdate>>>PastDateField().db_value(date(year=2010,month=1,day=1))datetime.date(2010,1,1)>>>PastDateField().db_value(date(year=2017,month=1,day=1))datetime.date(2017,1,1)>>>PastDateField().db_value(date(year=2020,month=1,day=1))Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PastDateFieldDatesValueisnotinthePast (validvaluesmustbeinthePast):2020-01-01.>>>print(PastDateField().get_html_widget())<inputtype="date"name="date"max="2017-12-14">
peewee_extra_fields.PastDateTimeField()
Description:DateTimeField
subclass but only accepts datesNot on the Future values.Past is Ok, Present is Ok, Future is Not Ok.Most of times you need DateTimes on the Past, eg. your Birthday cant be in the Future.
This Field has an additional helper method for lazy devs:peewee_extra_fields.PastDateTimeField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asDateTimeField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asDateTimeField
).
Returns:datetime
.
Base Class:DateTimeField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPastDateTimeField>>>fromdatetimeimportdatetime>>>PastDateTimeField().db_value(datetime(year=2010,month=1,day=1))datetime.datetime(2010,1,1,0,0)>>>PastDateTimeField().db_value(datetime(year=2017,month=1,day=1))datetime.datetime(2017,1,1,0,0)>>>PastDateTimeField().db_value(datetime(year=2020,month=1,day=1))Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:PastDateTimeFieldDates&TimesValueisnotinthePast (validvaluesmustbeinthePast):2020-01-0100:00:00.>>>print(PastDateTimeField().get_html_widget())<inputtype="datetime-local"name="datetime"max="2017-12-14T04:40">
peewee_extra_fields.LanguageISOCodeField()
Description:FixedCharField
subclass but only acceptsLanguage ISO Code values (ISO-639_1).Uses hardcodedmax_length = 2
.
This Field has an additional helper method for lazy devs:peewee_extra_fields.LanguageISOCodeField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Returns:collections.namedtuple
.
Base Class:FixedCharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportLanguageISOCodeField>>>LanguageISOCodeField().db_value("en")'en'>>>LanguageISOCodeField().db_value("es")'es'>>>LanguageISOCodeField().python_value("es")LanguageISO639(code='es',name='Spanish')>>>LanguageISOCodeField().python_value("en")LanguageISO639(code='en',name='English')>>>LanguageISOCodeField().db_value("not valid")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:LanguageISOCodeFieldValueis9Characterslonginsteadof2Characterslong (validvaluesmustbeISO-639_1LanguageCodes):notvalid.>>>LanguageISOCodeField().db_value("xx")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:LanguageISOCodeFieldValueisnotanISO-639_1StandardLanguageCodeof2Characterslong (validvaluesmustbeISO-639_1LanguageCodes):xx.>>>print(LanguageISOCodeField().get_html_widget())<selectname="language"><optionselecteddisabledvalue=""></option><optionvalue="aa">(AA)Afar (afaraf)</option><optionvalue="af">(AF)Afrikaans (afrikaans)</option><optionvalue="ak">(AK)Akan (akan)</option># . . . All the other ISO-639 Languages here on several HTML option elements autogenerated for you . . .<optionvalue="xh">(XH)Xhosa (isixhosa)</option><optionvalue="zu">(ZU)Zulu (isizulu)</option></select>
peewee_extra_fields.CountryISOCodeField()
Description:SmallIntegerField
subclass only acceptsCountry ISO Code string values.
It converts the 2-Characters Country ISO Code to integer Country ISO Code,saves to Database the SmallInt, when reading from Database, reverts back,small integer Country ISO Code to 2-Characters string Country ISO Code.
Returns 1 namedtuple with iso3166_a3, iso3166_numeric, capital, continent,currency_code, currency_name, geoname_id, is_developed, is_independent,languages, name, name_human, phone_code, timezones and tld.
This always stores only small positive Integer numbers of 3 digits max,that maps 1-to-1 to 2-Characters string Country Codes, according to ISO.
Small integer is always faster than varchar or text in every aspect.
This Field has an additional helper method for lazy devs:peewee_extra_fields.CountryISOCodeField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asSmallIntegerField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asSmallIntegerField
).
Returns:collections.namedtuple
.
Base Class:SmallIntegerField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportCountryISOCodeField>>>CountryISOCodeField().db_value("ar")32>>>CountryISOCodeField().python_value(32)CountryISO3166(iso3166_a3='ARG',iso3166_numeric=32,capital='Buenos Aires',continent='Americas',currency_code='ARS',currency_name='Argentine Peso',geoname_id=3865483,is_developed=False,is_independent=True,languages=['es-AR','en','it','de','fr','gn'],name='Argentina',name_human='The Argentine Republic',phone_code='54',timezones=['america/argentina/buenos_aires','america/argentina/cordoba','america/argentina/jujuy','america/argentina/tucuman','america/argentina/catamarca','america/argentina/la_rioja','america/argentina/san_juan','america/argentina/mendoza','america/argentina/rio_gallegos','america/argentina/ushuaia'],tld='.ar')>>>CountryISOCodeField().db_value("xx")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:CountryISOCodeFieldValueisnotanISO-3166StandardCountryCodeof2Characterslong (validvaluesmustbeISO-3166CountryCodes):xx.>>>print(CountryISOCodeField().get_html_widget())<selectname="country"><optionselecteddisabledvalue=""></option><optionvalue="ad"data-iso3166numeric="20"data-iso3166a3="and">(AD)Andorra</option><optionvalue="ae"data-iso3166numeric="784"data-iso3166a3="are">(AE)UnitedArabEmirates</option><optionvalue="af"data-iso3166numeric="4"data-iso3166a3="afg">(AF)Afghanistan</option># . . . All the other ISO-3166 Countries here on several HTML option elements autogenerated for you . . .<optionvalue="za"data-iso3166numeric="710"data-iso3166a3="zaf">(ZA)SouthAfrica</option><optionvalue="zm"data-iso3166numeric="894"data-iso3166a3="zmb">(ZM)Zambia</option><optionvalue="zw"data-iso3166numeric="716"data-iso3166a3="zwe">(ZW)Zimbabwe</option></select>
peewee_extra_fields.CurrencyISOCodeField()
Description:SmallIntegerField
subclass only acceptsCurrency ISO Code values.
It converts 3-Characters Currency ISO Code to integer Currency ISO Code,saves to Database the SmallInt, when reading from Database, reverts back,small integer Currency ISO Code to 3-Characters string Currency ISO Code.
Returns 1 namedtuple with code, name, iso4217_numeric.
This always stores only small positive Integer numbers of 3 digits max,that maps 1-to-1 to 3-Characters string Currency Codes, according to ISO.
Small integer is always faster than varchar or text in every aspect.
This Field has an additional helper method for lazy devs:peewee_extra_fields.CurrencyISOCodeField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asSmallIntegerField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asSmallIntegerField
).
Returns:collections.namedtuple
.
Base Class:SmallIntegerField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportCurrencyISOCodeField>>>CurrencyISOCodeField().db_value("usd")840>>>CurrencyISOCodeField().python_value(840)CurrencyISO4217(code='usd',name='United States Dollar',iso4217_numeric=840)>>>CurrencyISOCodeField().db_value("not valid")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:CurrencyISOCodeFieldValueis9Characterslonginsteadof3Characterslong (validvaluesmustbeISO-4217CurrencyCodes):notvalid.>>>CurrencyISOCodeField().db_value("lol")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:CurrencyISOCodeFieldValueisnotanISO-4217StandardCurrencyCodeof3Characterslong (validvaluesmustbeISO-4217CurrencyCodes):lol.>>>print(CurrencyISOCodeField().get_html_widget())<selectname="currency"><optionselecteddisabledvalue=""></option><optionvalue="aed"data-iso4217numeric="784">(AED)UnitedArabEmiratesDirham</option><optionvalue="afn"data-iso4217numeric="971">(AFN)AfghanAfghani</option><optionvalue="all"data-iso4217numeric="8">(ALL)AlbanianLek</option># . . . All the other ISO-4217 Currencies here on several HTML option elements autogenerated for you . . .<optionvalue="zar"data-iso4217numeric="710">(ZAR)SouthAfricanRand</option><optionvalue="zmw"data-iso4217numeric="967">(ZMW)ZambianKwacha</option><optionvalue="zwl"data-iso4217numeric="932">(ZWL)ZimbabweanDollar</option></select>
peewee_extra_fields.SWIFTISOCodeField()
Description:CharField
subclass but only acceptsSWIFT-Codes ISO-9362 values (SWIFT Business Identifier Code BIC ISO-9362:2014, AKA SWIFT).
Has a hardcodedmax_length = 11
according to ISO-9362 Standard.
country_code
must be a valid ISO-3166 country code according to ISO-9362 Standard.
branch_code
can be astr
orNone
according to ISO-9362 Standard.
This code is also known as: SWIFT-BIC, BIC code, SWIFT ID, SWIFT code or ISO-9362.
Returns acollections.namedtuple
withbank_code
,country_code
,location_code
,branch_code
,swift
.
Arguments: None (should take the same*args
and**kwargs
asCharField
)
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:collections.namedtuple
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportSWIFTISOCodeField>>>SWIFTISOCodeField().python_value("DEUTDEFF")SWIFTCodeISO9362(bank_code='DEUT',country_code='DE',location_code='FF',branch_code=None,swift='DEUTDEFF')>>>SWIFTISOCodeField().python_value("NEDSZAJJ")SWIFTCodeISO9362(bank_code='NEDS',country_code='ZA',location_code='JJ',branch_code=None,swift='NEDSZAJJ')>>>SWIFTISOCodeField().python_value("DABADKKK")SWIFTCodeISO9362(bank_code='DABA',country_code='DK',location_code='KK',branch_code=None,swift='DABADKKK')>>>SWIFTISOCodeField().python_value("UNCRITMM")SWIFTCodeISO9362(bank_code='UNCR',country_code='IT',location_code='MM',branch_code=None,swift='UNCRITMM')>>>SWIFTISOCodeField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:SWIFTISOCodeFieldValuestringisnotaValidSWIFT-CodeISO-9362:2014 (validvaluesmustnotbeanEmptyString):"".>>>SWIFTISOCodeField().db_value("None")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:SWIFTISOCodeFieldValuestringisnotaValidSWIFT-CodeISO-9362:2014 (validvaluesmustbeavalidSWIFT-Codeof8or11characterslong):NONE.
peewee_extra_fields.IBANISOCodeField()
Description:CharField
subclass but only acceptsIBAN-Codes ISO 13616:2007 values (International Bank Account Number (IBAN).
Has a hardcodedmax_length = 34
according to ISO-13616 Standard.
country_code
must be a valid ISO-3166 country code according to ISO-13616 Standard.
Returns acollections.namedtuple
withcountry_code
,checksum
,bban
,iban_pretty
,iban
.
Arguments: None (should take the same*args
and**kwargs
asCharField
)
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:collections.namedtuple
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportIBANISOCodeField>>>IBANISOCodeField().db_value("DE44 5001 0517 5407 3249 31")'DE44500105175407324931'>>>IBANISOCodeField().python_value("DE44 5001 0517 5407 3249 31")SWIFTCodeISO9362(country_code='DE',check_code='44',bban='500105175407324931',iban_pretty='DE44 5001 0517 5407 3249 31',iban='DE44500105175407324931')>>>IBANISOCodeField().python_value("GB29 NWBK 6016 1331 9268 19")SWIFTCodeISO9362(country_code='GB',check_code='29',bban='NWBK60161331926819',iban_pretty='GB29 NWBK 6016 1331 9268 19',iban='GB29NWBK60161331926819')>>>IBANISOCodeField().python_value("SA03 8000 0000 6080 1016 7519")SWIFTCodeISO9362(country_code='SA',check_code='03',bban='80000000608010167519',iban_pretty='SA03 8000 0000 6080 1016 7519',iban='SA0380000000608010167519')>>>IBANISOCodeField().python_value("CH93 0076 2011 6238 5295 7")SWIFTCodeISO9362(country_code='CH',check_code='93',bban='00762011623852957',iban_pretty='CH93 0076 2011 6238 5295 7',iban='CH9300762011623852957')>>>IBANISOCodeField().python_value("GB82 WEST 1234 5698 7654 32")SWIFTCodeISO9362(country_code='GB',check_code='82',bban='WEST12345698765432',iban_pretty='GB82 WEST 1234 5698 7654 32',iban='GB82WEST12345698765432')>>>IBANISOCodeField().db_value("DEzz 5001 0517 5407 3249 31")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IBANISOCodeFieldValuestringisnotaValidIBAN-CodeISO-13616:2007 (validvaluesmustbeavalidIBAN-Code,mustcontainaValidIBANCheckSumDigit):DEZZ500105175407324931->zz.>>>IBANISOCodeField().db_value("DE00 5001 0517 5407 3249 31")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IBANISOCodeFieldValuestringisnotaValidIBAN-CodeISO-13616:2007 (validvaluesmusthaveavalidIBANCheckSumdigits):DE00500105175407324931->00.>>>IBANISOCodeField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IBANISOCodeFieldValuestringisnotaValidIBAN-CodeISO-13616:2007 (validvaluesmustnotbeanEmptyString):"".>>>IBANISOCodeField().db_value("DE00 5001 0517 5407 3249 3100 0000 0000 0000")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IBANISOCodeFieldValuestringisnotaValidIBAN-CodeISO-13616:2007 (validvaluesmustbeavalidIBAN-CodeISO-13616of34charactersmax):DE0050010517540732493100000000000000.
peewee_extra_fields.IANCodeField()
Description:CharField
subclass but only acceptsIAN Codes values, International Article Number (AKA European Article Number or EAN or IAN).
Has a hardcodedmax_length = 13
according to Wikipedia.
Notice this is not an ISO Standard, if you work with this codes, any improvement is welcome.
CheckSum for 8 to 13 IAN-Codes only.
Arguments: None (should take the same*args
and**kwargs
asCharField
)
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportIANCodeField>>>IANCodeField().db_value("5901234123457")'5901234123457'>>>IANCodeField().db_value("4012345123456")'4012345123456'>>>IANCodeField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IANCodeFieldValuestringisnotaValidInternationalArticleNumber (IAN) (validvaluesmustnotbeanEmptyString):"".>>>IANCodeField().db_value("1234567896765756756")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IANCodeFieldValuestringisnotaValidInternationalArticleNumber (IAN) (validvaluesmustbeavalidIANof13charactersmax):1234567896765756756.>>>IANCodeField().db_value("1234567890")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:IANCodeFieldValuestringisnotaValidInternationalArticleNumberIAN8~13Characters (validvaluesmusthaveavalidIANCheckSumint):1234567890.
peewee_extra_fields.ColorHexadecimalField()
Description:FixedCharField
subclass but only acceptsColors on Hexadecimal values (4 & 7 chars format).Format is 3 or 6 Hexadecimal characters, eg"#00ff00"
,"#be0"
, etc.Values must start with a"#"
.Values must be 4 or 7 characters long.Has a hardcodedmax_length = 7
.
Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Returns:collections.namedtuple
.
Base Class:FixedCharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportColorHexadecimalField>>>ColorHexadecimalField().db_value("#f0f0f0")'#f0f0f0'>>>ColorHexadecimalField().db_value("#be0")'#bbee00'>>>ColorHexadecimalField().db_value("#fe0")'#ffee00'>>>ColorHexadecimalField().db_value("#bebebe")'#bebebe'>>>ColorHexadecimalField().python_value("#f0f0f0")Color(hex='#f0f0f0',rgb=RGB(red=240,green=240,blue=240),hls=HLS(h=0.0,l=240.0,s=0.0),hsv=HSV(h=0.0,s=0.0,v=240),yiq=YIQ(y=240.0,i=0.0,q=0.0),css='rgb(240,240,240)',css_prcnt='rgb(94%,94%,94%)')>>>ColorHexadecimalField().python_value("#ffee00")Color(hex='#ffee00',rgb=RGB(red=255,green=238,blue=0),hls=HLS(h=0.16,l=127.5,s=-1.01),hsv=HSV(h=0.16,s=1.0,v=255),yiq=YIQ(y=216.92,i=86.75,q=-70.66),css='rgb(255,238,0)',css_prcnt='rgb(100%,93%,0%)')>>>ColorHexadecimalField().python_value("#ffee00").hex'#ffee00'>>>ColorHexadecimalField().python_value("#bebebe")Color(hex='#bebebe',rgb=RGB(red=190,green=190,blue=190),hls=HLS(h=0.0,l=190.0,s=0.0),hsv=HSV(h=0.0,s=0.0,v=190),yiq=YIQ(y=190.0,i=0.0,q=0.0),css='rgb(190,190,190)',css_prcnt='rgb(74%,74%,74%)')>>>ColorHexadecimalField().db_value("#bebehh")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ColorHexadecimalFieldValueisnotanHexadecimal (valuesmustbeHexadecimals):#bebehh invalid literal for int() with base 16: 'bebehh'>>>ColorHexadecimalField().db_value("#bebe")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ColorHexadecimalFieldValueis5Characterslonginsteadof7or4Characterslong (validvaluesmustbeexactly7or4characters):#bebe.>>>ColorHexadecimalField().db_value("#bebebe0")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ColorHexadecimalFieldValueis8Characterslonginsteadof7or4Characterslong (validvaluesmustbeexactly7or4characters):#bebebe0.>>>ColorHexadecimalField().db_value("bebebeb")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ColorHexadecimalFieldValueisnotavalidRGBHexadecimalColorvalueof7characterslong (validvaluesmuststartwith'#'):bebebeb.
peewee_extra_fields.SemVerField()
Description:CharField
subclass but only acceptsSemantic Versions values (from 5 to 255 chars format).Format standard spec is fromhttps://semver.org.Has a hardcodedmax_length = 255
as recommended on semver.org.
Arguments: None (should take the same*args
and**kwargs
asCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportSemVerField>>>SemVerField().db_value("1.0.0")'1.0.0'>>>SemVerField().db_value("0.0.1")'0.0.1'>>>SemVerField().db_value("v1.0.0")'v1.0.0'>>>SemVerField().db_value("1.2.3-alpha.10.beta.0+build.unicorn.rainbow")'1.2.3-alpha.10.beta.0+build.unicorn.rainbow'>>>SemVerField().db_value("0.0.0-foo")'0.0.0-foo'>>>SemVerField().db_value("2.7.2-foo+bar")'2.7.2-foo+bar'>>>SemVerField().db_value("1.2.3-alpha.10.beta.0")'1.2.3-alpha.10.beta.0'>>>SemVerField().db_value("99.0.0")'99.0.0'>>>SemVerField().db_value("2.7.2+asdf")'2.7.2+asdf'>>>SemVerField().db_value("1.2.3-a.b.c.10.d.5")'1.2.3-a.b.c.10.d.5'>>>SemVerField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:SemVerFieldValueisnotavalidSemanticVersionstring,from5to255characterslong(validvaluesmustmatchaRegex"\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b"): .>>>SemVerField().db_value("0a")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:SemVerFieldValueisnotavalidSemanticVersionstring,from5to255characterslong (validvaluesmustmatchaRegex"\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b"):0a.>>>SemVerField().db_value("cat")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:SemVerFieldValueisnotavalidSemanticVersionstring,from5to255characterslong (validvaluesmustmatchaRegex"\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b"):cat.
peewee_extra_fields.ARPostalCodeField()
Description:CharField
subclass but only acceptsArgentine Postal Codes (old & new).
This Field has an additional helper method for lazy devs:peewee_extra_fields.ARPostalCodeField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportARPostalCodeField>>>ARPostalCodeField().db_value("2804")'2804'>>>ARPostalCodeField().db_value("666")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ARPostalCodeFieldValueisnotavalidArgentinePostalCode (old&new)stringof4to8characterslong:666.>>>print(ARPostalCodeField().get_html_widget())<inputtype="text"name="postal-code"placeholder="Codigo Postal Argentino"minlength="4"maxlength="8"size="8">
peewee_extra_fields.ARCUITField()
Description:CharField
subclass but only acceptsArgentine CUIT, also it can extract DNI from CUIT.
This Field has an additional helper method for lazy devs:peewee_extra_fields.ARCUITField().get_html_widget(clas: tuple=None, ids: str=None, required: bool=False)
that will build and return a string with 1 HTML5 widget element fit for purpose for the possible values of the Field,No CSS, No JS, Nothing Embed, just plain clear text HTML,you can set the DOM Classes withclass
argument oftuple
type, you can set the DOM ID withids
argument ofstr
type,you can set the DOM "required" withrequired
argument ofbool
type, return type is alwaysstr
,it just returns an string does not affect the internals of the Field.
Arguments: None (should take the same*args
and**kwargs
asCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportARCUITField>>>ARCUITField().db_value("20-30999666-6")'20309996666'>>>ARCUITField().db_value("20309996666")'20309996666'>>>ARCUITField().cuit2dni("20-30999666-6")30999666>>>ARCUITField().db_value("20-30999-6")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:ARCUITFieldValueisnotavalidArgentineCUITCodestringof11to13characterslong:20-30999-6.>>>print(ARCUITField().get_html_widget())<inputtype="text"name="cuit"placeholder="CUIT Argentino"minlength="10"maxlength="13"size="13">
peewee_extra_fields.USZipCodeField()
Description:CharField
subclass but only acceptsUS ZIP Codes (XXXXX or XXXXX-XXXX).
Arguments: None (should take the same*args
and**kwargs
asCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportUSZipCodeField>>>USZipCodeField().db_value("20521-9000")'20521-9000'>>>USZipCodeField().db_value("99750-0077")'99750-0077'>>>USZipCodeField().db_value("12201-7050")'12201-7050'>>>USZipCodeField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USZipCodeFieldValueisnotavalidUSAZIPCodes (XXXXXorXXXXX-XXXX)stringfrom5to10characterslong (validvaluesmustmatchaRegex"^\d{5}(?:-\d{4})?$"):"".>>>USZipCodeField().db_value("1")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USZipCodeFieldValueisnotavalidUSAZIPCodes (XXXXXorXXXXX-XXXX)stringfrom5to10characterslong (validvaluesmustmatchaRegex"^\d{5}(?:-\d{4})?$"):1.>>>USZipCodeField().db_value("20521-90000")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USZipCodeFieldValueisnotavalidUSAZIPCodes (XXXXXorXXXXX-XXXX)stringfrom5to10characterslong (validvaluesmustmatchaRegex"^\d{5}(?:-\d{4})?$"):20521-90000.
peewee_extra_fields.USSocialSecurityNumberField()
Description:FixedCharField
subclass but only acceptsU.S.A. Social Security Numbers (XXX-XX-XXXX format).Has a hardcodedmax_length = 11
.Returns anamedtuple
withssn
,area
,group
,serial
.
Checks that values conforms to theXXX-XX-XXXX
format.
Area, Group, Serial must not be all Zeroes.
Group must not be"666"
.
Must not be in the "promotional block"987-65-4320
~987-65-4329
.
Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asFixedCharField
).
Returns:collections.namedtuple
.
Base Class:FixedCharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportUSSocialSecurityNumberField>>>USSocialSecurityNumberField().db_value("205-21-9000")'205-21-9000'>>>USSocialSecurityNumberField().python_value("205-21-9000")USSocialSecurityNumber(ssn='205-21-9000',area=205,group=21,serial=9000)>>>USSocialSecurityNumberField().db_value("205-21-90")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USSocialSecurityNumberFieldValueisnotavalidU.S.A.SocialSecurityNumberstring (XXX-XX-XXXXformat) (validSocialSecurityNumbervaluesbeamustmatchaRegex'^(?P<area>\\d{3})[-\\ ]?(?P<group>\\d{2})[-\\ ]?(?P<sri>\\d{4})$'):205-21-90->None.In [7]:USSocialSecurityNumberField().db_value("")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USSocialSecurityNumberFieldValueisnotavalidU.S.A.SocialSecurityNumberstring (XXX-XX-XXXXformat) (validSocialSecurityNumbervaluesbeamustmatchaRegex'^(?P<area>\\d{3})[-\\ ]?(?P<group>\\d{2})[-\\ ]?(?P<sri>\\d{4})$'):->None.In [8]:USSocialSecurityNumberField().db_value("1")Traceback (mostrecentcalllast):File"<stdin>",line1,in<module>ValueError:USSocialSecurityNumberFieldValueisnotavalidU.S.A.SocialSecurityNumberstring (XXX-XX-XXXXformat) (validSocialSecurityNumbervaluesbeamustmatchaRegex'^(?P<area>\\d{3})[-\\ ]?(?P<group>\\d{2})[-\\ ]?(?P<sri>\\d{4})$'):1->None.
peewee_extra_fields.PasswordField()
Description: PeeweePasswordField backported from 2.x Versions (literal copy & paste) to work with Peewee 3 and Python 3.PasswordField
stores a password hash and lets you verify it.The password is hashed when it is saved to the database andafter reading it from the database you can call:check_password(password)
to return abool
.
This field requiresbcrypt
, which can be installed by runningpip install bcrypt
.peewee_extra_fields
still works Ok withoutbcrypt
.
PasswordField
is explicitly no longer supported and deprecated by Peewee.
This field has been clean out of Legacy Python2 compatibility code that it originally used to have.
This field is to support code already using Peewee 2.xPasswordField
,if you are implementing from zero, checkSimplePasswordField
that uses new Pythonsecrets
from standard lib.
Arguments: None (should take the same*args
and**kwargs
asBlobField
).
Keyword Arguments: None (should take the same*args
and**kwargs
asBlobField
).
Returns:bytes
.
Base Class:BlobField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportPasswordField>>>PasswordField().db_value("a")b'$2b$12$9CMSMQYPkZ5RsWWrZccw7eqGrCQF679BhDA4dz6rG/e70FbQmeG.6'
peewee_extra_fields.SimplePasswordField()
Description: PeeweePasswordField re-implemented and simplified from 2.x Versions to work with Peewee 3 and Python 3 using newsecrets
andhashlib
from standard library, without dependencies, dont needbcrypt
,internally useshashlib.pbkdf2_hmac()
andsecrets.compare_digest()
.Migration fromPasswordField
toSimplePasswordField
is recommended when possible.
PasswordField
is explicitly no longer supported and deprecated by Peewee.
SimplePasswordField
stores a password hash and lets you verify it.The password is hashed when it is saved to the database andafter reading it from the database you can call:check_password(password)
to return abool
.
Arguments:
salt
Salt for Password hashing, string type, required, use some random string, checksecrets.token_hex()
andsecrets.token_urlsafe()
as sources of random strings.min_length
Minimum Password length, optional, integer type, positive value, defaults to8
.algorithm
Algorithm for Password hashing, optional, string type, dafaults to"sha512"
.iterations
Iterations for Password hashing, optional, integer type, positive value, defaults to100_000
.dklen
Output Hash length, optional, integer type orNone
, positive value, defaults toNone
, automatic and constant length based onalgorithm
is used if set toNone
.
Keyword Arguments: None (should take the same*args
and**kwargs
asCharField
).
Returns:str
.
Base Class:CharField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
Usage Example:
>>>frompeewee_extra_fieldsimportSimplePasswordField>>>SimplePasswordField(salt="abc").db_value("123456789")'46b071b59b995e1a668e68d2112b829ad04e0d988ac989ba2ecc0e56ad8a72780081381f2b6f38573d294454b569d7f1d3bce9cc08edcec6f68f6584357b72a9'
peewee_extra_fields.EnumField()
Description: PeeweeSmallIntegerField re-implemented to work withPythonsenum.Enum
.
Arguments:
enum
a Pythonenum.Enum
object, required, Enum type.
Keyword Arguments: None (should take the same*args
and**kwargs
asSmallIntegerField
).
Returns: Whatever your Enum values has.
Base Class:SmallIntegerField
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields/__init__.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
peewee_extra_fields.MoneyField()
Description: Peewee custom Field implemented to work with Monetary values,uses Native Money database type,for Money values is faster than using Pythonfloat
orDecimal
fields,provides automatic smart formatting on money values,requires the argumentfield_types=peewee_extra_fields.FIELD_TYPES
when instancing the Postgres connection likedb = PostgresqlDatabase('test', field_types=peewee_extra_fields.FIELD_TYPES)
,value limits are from $ -92233720368547758.08 to $ +92233720368547758.07.
Arguments:
value
A Monetary value, required, 1 ofint
,float
,str
,Decimal
or None types.
Keyword Arguments: None.
Returns: str.
Base Class:Field
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields/__init__.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
peewee_extra_fields.XMLField()
Description: Peewee custom Field implemented to work with XML like values,uses Native XML database type,for XML like values is faster than using Pythonstr
fields,requires the argumentfield_types=peewee_extra_fields.FIELD_TYPES
when instancing the Postgres connection likedb = PostgresqlDatabase('test', field_types=peewee_extra_fields.FIELD_TYPES)
,values are parsed using Pythonsxml.etree.ElementTree.fromstring(value)
,works with XML, SVG, XHTML, etc.
Arguments:
value
Valid XML value, required,str
type.
Keyword Arguments: None.
Returns: str.
Base Class:Field
.
Type:<class 'type'>
.
Source Code file:https://github.com/juancarlospaco/peewee-extra-fields/blob/master/peewee_extra_fields/__init__.py
State | OS | Description |
---|---|---|
✅ | Linux | Works Ok |
✅ | Os X | Works Ok |
✅ | Windows | Works Ok |
- Check an actual working Example copied from official Peewee docs. Run it executing on the terminal command line:
python example.py
.
pip install peewee_extra_fields
- Peewee(2.x or 3.x Versions)
Optional:
- Pull requests to improve tests are welcome!!!.
python -m unittest --verbose --locals tests.TestFields# ORpython -m unittest# ORpytest
Maximum performance for advanced Linux users.
sudo pip install cython
Cython basically translates Python 3 to C and then Compiles C to Binary,then you can import the generated*.so
module as a normal Python module.
Its 100% Optional, but recommend. We check that Cython Compiles on Travis.
You dont have to learn anything about Cython, it just works automatically.The Packages on PyPi dont have any*.c
,*.cpp
,*.pyc
,*.so
.
Cython is used by lots of projects and companies.Please check Cython documentation for more info.
- Please Star this Repo on Github !, it helps to show up faster on searchs.
- Help and moreHelp and Interactive QuickGit Tutorial.
- English is the primary default spoken language, unless explicitly stated otherwise(eg. Dont send Translation Pull Request)
- Pull Requests for working passing unittests welcomed.
About
Extra Fields for Peewee 3 on Python 3.
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Languages
- Python100.0%