title: Max and min values for a Django model field, according to the values already introduced
body: <p>I want to create a model in Django where I could introduce integer values for a given field, with limits depending on the values already introduced for that field. Specifically, I would like the value introduced to be in the range of (min = 1 | max = maximum value for that field +1)
  The code should be something like that in the models.py file:</p>
  <pre><code>from django.db import models
  from django.core.validators import MaxValueValidator, MinValueValidator
  
  class MyModel(models.Model):
      max_myfield = MyModel.objects.filter(myfield=self.myfield).aggregate(Max('myfield'))[&quot;myfield_max&quot;]
      myfield = models.IntegerField(validators=[MinValueValidator=1, MaxValueValidator=max_myfield + 1])
  </code></pre>
  <p>The problem with this is that max_myfield is using the MyModel itself, raising a NameError as it is not defined yet.</p>
  <p>In addition, if there is no record in the table, the max value shall be also 1, like the minimum.</p>
  <p><strong>EDIT:</strong>
  I want to simplify the question to the following:
  <em><strong>What should I do in the models.py file of a Django application, if I want to define a model with fields which validators shall depend somehow on the model fields values?</strong></em></p>