only allow positiv prices
In order to only allow positiv prices I had import two new classes.
This commit is contained in:
parent
2ec5a9ca7e
commit
6b5bd3fe45
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
|
from django.core.validators import MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
@ -53,7 +55,10 @@ class Article(models.Model):
|
||||||
description = models.TextField(max_length=2000)
|
description = models.TextField(max_length=2000)
|
||||||
stock = models.FloatField(max_length=5)
|
stock = models.FloatField(max_length=5)
|
||||||
status = models.ForeignKey(ArticleStatus)
|
status = models.ForeignKey(ArticleStatus)
|
||||||
price_in_chf = models.DecimalField(max_digits=19, decimal_places=2)
|
price_in_chf = models.DecimalField(max_digits=19,
|
||||||
|
decimal_places=2,
|
||||||
|
validators=[MinValueValidator(
|
||||||
|
Decimal('0.00'))])
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
Loading…
Reference in New Issue