Search code examples
djangodjango-userena

django-userena: how to activate account for local development?


I just installed django-userena for my accounts management.

Because I'm still at the stage of basic development and I don't have a public domain name. I'm using gmail for my EMAIL_HOST for testing. The default setting from django-userena is using example.com for demo. How can I switch it to my local domain, i.e. 127.0.0.1:8000, so I can make some dummy "users" activated and test it for my other apps?

Thank you!!!

EDITED: Because I don't have a domain name, when the user click the activation email in his email(e.g. Gmail), it's directed to http://example.com/accounts/activate/hash_as_placeholder/, so the result is that the user can't activate his account. How can I let them activate their accounts on a local domain?


Solution

  • Try this. Add this lines to settings.py

    LOGIN_REDIRECT_URL = '/accounts/%(username)s/'  
    LOGIN_URL = '/accounts/signin/'  
    LOGOUT_URL = '/accounts/signout/'  
    

    and about email configuration, i have issues with gmail if i send a lot of mails. So for testing purposes i have this in my settings:

    EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' #printed in console
    

    All emails will be printed in console.

    EDITED: Create new file initial_data.json in your project root with

    [{
    "pk": 1,
    "model": "sites.site",
    "fields": {
       "name": "127.0.0.1:8000",
       "domain":"127.0.0.1:8000"
       }
    }]
    

    and run syncdb of course. This will change your example.com to 127.0.0.1:8000