I would move this functionality inside `ExternalAccount` model. Build a `get_url` function which will calculate the url based on type. Feed the `profile.html` template directly with the `QuerySet` and call the new function from the template. 

Extra bonus: Build the function in a way that the username can be in other places of the url instead of just in the end. Maybe we have services in the future with urls like

`http://example.com/USERNAME/profile`

or something like that instead of

`http://example.com/USERNAME/`