So, im trying to work on my apps and I have PositiveBigIntegerField's in some of my models. I thought for sure it was already included with Django but now i'm starting to think otherwise. Whenever I run my server, im getting an error stating that AttributeError: module 'django.db.models' has no attribute 'PositiveBigIntegerField'
Has anyone run into this problem before?
Asked
Active
Viewed 1,248 times
2

Sunderam Dubey
- 1
- 11
- 20
- 40

Alec
- 27
- 8
-
What version of Django do you use? This was new in Django-3.1. – Willem Van Onsem Jul 18 '22 at 18:40
1 Answers
2
So, I'm trying to work on my apps and I have PositiveBigIntegerField's in some of my models. I thought for sure it was already included with Django but now I'm starting to think otherwise.
It is, but only since django-3.1. Indeed, the documentation of the PostiveBigIntegerField
[Django-doc] specifies that this was introduced then.
You can however easily implement this yourself, as specified in the source code [GitHub]:
class PositiveBigIntegerField(PositiveIntegerRelDbTypeMixin, BigIntegerField): description = _("Positive big integer") def get_internal_type(self): return "PositiveBigIntegerField" def formfield(self, **kwargs): return super().formfield( **{ "min_value": 0, **kwargs, } )
Where you thus import PositiveIntegerRelDbTypeMixin
and BigIntegerField
from the django.db.models.fields
module.

Willem Van Onsem
- 443,496
- 30
- 428
- 555