I'm trying to implement signup with confirmation email with Django using SendGrid as email provider, my 'SignUpActivationView' code validates the token and then redirects the user to the home page, where a success/error message is displayed using the messages framework:
class SignUpActivationView(RedirectView):
redirect_url = reverse_lazy('link_list')
def dispatch(self, request, *args, **kwargs):
...
# if token is valid:
messages.error(self.request, 'Your account is now active.')
return HttpResponseRedirect(self.redirect_url)
# if token is invalid:
messages.error(self.request, 'Your account could not be activated.')
return HttpResponseRedirect(self.redirect_url)
So far my approach works as long as I copy-paste the link in my browser, if I click on it instead, the user is activated but the success message is not shown in my application. I believe this is because SendGrid's Click Tracking service is wrapping my link:
A workaround I found is to tell SendGrid to NOT track the link by adding and the 'clicktracking=off' HTML attribute, the disadvantage is that I can only tell SendGrid not to track links in the HTML version of my email. In case the user's email client decides to open the Plain text version of the email, then link will still be wrapped.
# solution: do not track clicks
# caveat: only works in HTML, not in plain text emails
<a clicktracking=off href="http://foo.bar">Confirmation link</a>
So Link Tracking is pretty month mandatory for Plain text emails.
Is there any way to make the messages framework work with Link Tracking?