question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'MaxValueValidator' is not defined

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
thenewguycommented, Oct 7, 2019

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.

from django.core.validators import MaxValueValidator
1reaction
fedonkincommented, Oct 7, 2019

Or provide more code so we can see what your problem is. Did you just copy and paste? You have to import the validator from Django

Yes, copied and pasted. Is there an example of how to import a validator from django?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found