Issue
In Django I'm trying to create a model which will contain a field for player's shirt numbers and was wondering if there is a way to restrict the field to be only numerical inputs. Currently I have in the models.py
number = models.CharField(max_length=2)
Is there a different field to CharField that will allow me to restrict the input to only numbers?
Solution
One of the cool things about Django that it provides you with different types of models read about them here.
For your case try something like this
number = models.IntegerField()
You can read more about the IntegerField
here
Answered By - Khaled Al-Ansari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.