title: How to make a form field numeric only in Django
body: <p>While using Django modelforms I have a <strong>Integer field</strong> which is numeric only. <strong>But in the browser it comes as a text field</strong> in which I can enter "characters". I want to make this only "numeric". How to do this ? i.e. <strong>users should be able to enter only numbers</strong>. </p>
  
  <p>We can do it 1 way by setting the attribute of the field. </p>
  
  <p>1) </p>
  
  <pre><code>def __init__(self,*args,**kwargs):
  
          super(PropertyForm,self).__init__(*args, **kwargs)        
          self.fields['brokers_phone_number'].widget.attrs['type'] = "number"
  </code></pre>
  
  <p>This does not seem to work. I am using html 5 and the browser is Chrome. What am I doing wrong ? How can It be done better ?</p>