Advantages to using URLField over TextField?

URLField is actually CharField w/ supporting of Regexp-based URL pattern checking and a online validator(which was replaced by a RegEx based validator), you could use TextField if you don’t care length-limitation of URL

from django.core.validators import URLValidator

# in model
field = models.TextField(validators=[URLValidator()])

Furthermore, using of CharField or TextField depends on whether you want max-length constraint on the field, and which element type is more suitable for editing: textarea or input. On PostgreSQL side, there is no significant difference.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)