'MaxValueValidator' is not defined
See original GitHub issueI do according to the instruction, https://jamesramm.github.io/longclaw/docs/tutorial/products
gives an error:
name 'MaxValueValidator' is not defined
Swears at it:
discount_percent = models.PositiveSmallIntegerField(default=20, validators=[MaxValueValidator(75)])
\
I do not understand how to fix 😦 heeelp
longclaw version: 1.0.2 Django version: 2.2.6 Python version: 3.7
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
'MaxValueValidator' is not defined · Issue #263 - GitHub
I do according to the instruction, https://jamesramm.github.io/longclaw/docs/tutorial/products gives an error: name 'MaxValueValidator' is ...
Read more >validators = [MinValueValidator] does not work in Django
Your code: from django.core.validators import MaxValueValidator, MinValueValidator max_discount = models.FloatField( verbose_name=u'Maximum ...
Read more >Validators - Django documentation
A validator is a callable that takes a value and raises a ValidationError if it doesn't meet some criteria. Validators can be useful...
Read more >Problem with date validator - Google Groups
Instead of relying on MaxValueValidator I suggest you write your own by simply defining the following function and passing in your field validators...
Read more >Problem With Maxvaluevalidator Limits On Floatfield Field
By default any extra attribute existing in stored data but not declared in your model will raise a. from django.core.validators import MaxValueValidator ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hrm, I cannot understand most of that. English please if possible.
But, the code you provided is incorrect. Django provides the MaxValueValidator out of the box. You just need to import it before you use it… hence the python NameError (https://docs.python.org/2/library/exceptions.html#exceptions.NameError). This isn’t a longclaw issue.
Yes, copied and pasted. Is there an example of how to import a validator from django?