Please use this code for the problem:

```python
if link is None:
    url = model.get_absolute_url()
else:
    try:
        url = model.get_absolute_url(link)
    except ValueError:
        url = ''
return url
```