Posts

Showing posts with the label URLField

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()])

URLField() in Django

 A URLField is a field of a database table or a form which stores only URLs. This field is generally used for storing webpage links called as URLs.  It is validated by URLValidator .  To store larger text, TextField is used. The default form widget for this field is TextInput .           Syntax:                field_name = models.URLField(max_length=250, **options)