W
W
wawa2018-04-01 14:45:25
Django
wawa, 2018-04-01 14:45:25

Why max_length in URLField, because there is no standard?

models.URLField is inherited from CharField, which enforces the need to specify a max_length limit.
Firstly: why so, because there is no standard for restriction
Secondly: what to do? to use TextField? If not, then what to set max_length, because I collect urls on the internet and cannot predict the maximum length. How are you doing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wawa, 2018-05-19
@wawa

from django.core.validators import URLValidator
field = models.TextField(validators=[URLValidator()])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question