I have a problem introducing NULL in Django. I mean, I donโt know how to do this.
I have a function, let's call it find_position , then I have a field in the model of type position (IntegerField, null = True, blank = True). This function checks some html code, and if it matches some regular expression, it returns an integer, but if it does not find it, it should return NULL or None or something that I can put into the database.
def find_position(self, to_find, something): ... if re.search(to_find, something): return i + (page * 10) + 1 return NULL
And I have this:
_position = find_position(to_find, something) p = Result(position=_position, ...) r.save()
Previously, I was a CharField user for position and returned a '-' if I could not find the result. But I had problems calculating the final results, such as position__lte = 10 (because it is not an integer , and it messed up with numbers and strings - .
What can i do with this?
source share