5

I am trying to update my code to the latest Django version, The method is_safe_url() seems to be removed from new version of Django (4.0). I have been looking for an alternative for the past few hours with no luck. Does anyone know of any alternatives for the method in Django 4.0?

p.ry
  • 409
  • 1
  • 8
  • 21

2 Answers2

12

in Django 3.0 they have renamed is_safe_url to url_has_allowed_host_and_scheme. Here you can read more about it docs

PTomasz
  • 1,330
  • 1
  • 7
  • 23
3

I think it has been renamed url_has_allowed_host_and_scheme(). You may also be interested in When do you need to use iri_to_uri after using url_has_allowed_host_and_scheme in Django?

wiml
  • 266
  • 3
  • 4