URLs for emails can't be configured for other domains
See original GitHub issueIt looks like djoser is restricted to using the current site’s object for building URLs (ie, ACTIVATE_URL
) which leaves you with the protocol and domain of the django server. This is a scenario that needs to be configurable, imho, to account for a frontend hosted on some other domain.
For example, I typically have a Django-based API on the api
domain (api.foobar.com) and web files served up on the www
domain (www.foobar.com) via some static-file-only CDN.
Evidence:
The djoser Activation Email object that produces an evaluated template: https://github.com/sunscrapers/djoser/blob/84f2ca4e7ce3dd05ce9b145fcc5353e77ebffc05/djoser/email.py#L8
The email template using protocol
/domain
:
https://github.com/sunscrapers/djoser/blob/84f2ca4e7ce3dd05ce9b145fcc5353e77ebffc05/djoser/templates/email/activation.html#L22
The django-templated-email handler that fills in the template:
(you could set DOMAIN
, sure, but this seems like a hack and likely will be disruptive to another module)
https://github.com/sunscrapers/django-templated-mail/blob/65e5a34f69d50d4d1b6acdd337f9efcc44b32fae/templated_mail/mail.py#L33
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7
Would something like this fly? This puts it in the context so it’s an override:
For those who want a fix until then, here is what I did for my app:
Everything should now work properly.