I have a model with a URL field in my Django project. I want to ensure that a scheme (like https://) is added to the URL if it doesn’t exist.
from django.db import models
class MyModel(models.Model):
url = models.URLField()
I’ve tried using the clean
, save
, clean_fields
methods, but none of them seem to work.
I feel there should be a straightforward way to accomplish this, but I can’t find one.
Any suggestions or best practices would be greatly appreciated.
Thanks!