Search code examples
djangofacebookdjango-authentication

Django inserts wrong domain to activation email, facebook auth and filebrowser


I've set up a Django project on a nginx server. But..

  1. Django detects request.get_host() in signup and activation views as localhost and sends email (for activation and password reset) with links like http://localhost/....

  2. I've set up Facebook authorization via social-auth-app-django. But Facebook tries to open redirect_uri in localhost (...redirect_uri=http:localhost/oauth/complete/facebook...)

  3. Inside django admin TinyMCE editor Filebrowser also refers to localhost..

How to fix these problems? Or it seems one solution can fix all of them.

Thank you for your time and help.


Solution

  • Did you tried changing your Site.domain and Site.name in admin panel or via shell? from django.contrib.sites.models import Site

    https://docs.djangoproject.com/en/2.1/ref/contrib/sites/

    It's used in many cases such as emails by default.