Advantages to using URLField() over TextField()

  • URLField is actually CharField which supports Regex-based URL pattern checking and a online validator which was replaced by a RegEx based validator, where as use TextField if you are not consider length-limitation of URL.
  • Use of CharField or TextField depends on whether you want max-length constraint on the field, and which element type is more suitable for editing like textarea or input.
        Ex:
        from django.core.validators import URLValidator
        url_field = models.TextField(validators=[URLValidator()])

Comments

Popular posts from this blog

Internationalization (Language Setting) in Django

reverse_lazy() Method in Django

CharFilter in Django