Issue
I want to store a list of numbers in Django model without using third party databases like MySQL, PostgreSQL etc. I want a simple approach. I don't think that there is any built-in field like PositiveSmallIntegerField, CharField etc but please do correct me if I am wrong. Is there a way I can use the built-in fields in order to achieve the result or is there a different approach? Please note that I need to add / remove / extract those numbers also.
Can someone help me with it?
Solution
Even easier, I believe it exists already...
from django.db.models.fields import CommaSeperatedIntegerField
and then you will notice that the system will advise you to use the following:
CharField(validators=[validate_comma_separated_integer_list])
and you can import validate_comma_separated_integer_list
from
from django.core.validators import validate_comma_separated_integer_list
Answered By - Swift
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.