Search code examples
pythondjangodjango-registration

Django-registration. The activation link sent is missing my app name


I am haviing issues with the django-registration module. When a user tries to register, the activation link that he receives in his email is not correct. I mean, for the link to work, I have to manually add my app's name right after the domain name.

Let me explain this with an example:

This is the main's page url (note the "HELLOPROJECT"): http://127.0.0.1:8000/HELLOPROJECT/index

This is the registration url (note the "HELLOPROJECT"): http://127.0.0.1:8000/HELLOPROJECT/accounts/register/

And this is the activation url sent in the email (note there is no "HELLOPROJECT"): http://127.0.0.1:8000/accounts/activate/3a97ec229308b0112cb6e1ef16f8ab32df667b9c/

If I click the above link, an error occurs. I have to manually add the "HELLOPROJECT" for the link to work properly and register the user.

So, why does this happen? How can I solve it?


Solution

  • The activation email template includes

    {{site}}/accounts/activate/{{ activation_key }}/
    

    Firstly make sure you have your copy of templates for registration correct. Then make sure your SITE_ID in settings.py matches the site you created. The djangoproject.com site is probably default and has id 1. If you edited the name of it to match your site, the id will remain same, if you add a new one find the new id and set your SITE_ID to that.

    site

    An object representing the site on which the user registered; depending on whether django.contrib.sites is installed, this may be an instance of either django.contrib.sites.models.Site (if the sites application is installed) or django.contrib.sites.models.RequestSite (if not). Consult the documentation for the Django sites framework for details regarding these objects' interface