Number Field
Table of contents
Example Usage
class User(Model):
salary = NumberField()
u = User(salary=1000)
u.save()
Allowed Attributes
The following attributes supported by DateTime Field.
-
Default
Default value for field. This is base attribute that is available in all fields. Read More
-
Required
Set
True
if value is required for the field. This is base attribute that is available in all fields. Read More -
Column Name
Set different column name in Firestore instead of field name. This is base attribute that is available in all fields. Read More
-
Validator
Validate given value of field. This is base attribute that is available in all fields Read More
-
Int Only
Allow only integer numbers. Other than integer number it will raise error
Example Usage
class User(Model):
salary = NumberField(int_only=True)
u = User(salary=1000)
u.save()
Allow only float numbers. Other than float number it will raise error
Example Usage
class User(Model):
salary = NumberField(float_only=True)
u = User(salary=21.37)
u.save()
Example Usage
class User(Model):
salary = NumberField(range=(100, 20000))
u = User(salary=1000)
u.save()
If you want to allow only max value set the start
as None
in this case there is no minimum limit
class User(Model):
salary = NumberField(range=(None, 20000))
To allow only minimum value set the stop
as None
or just put the start
value only
class User(Model):
salary = NumberField(range=(100, None)) # Equivalent to range=(100)