Shouldn't this be prefixed with a `else:`.
Ie. after `if not site_url:` the `site_url` will either be set or it will result in an exception.