Truthfully I didn’t know how to title my question. I’m testing a facebook signup api with my app. I have my localhost:8000 url and my livesite url. What I want to do, is have it recognize which one I’m using (local vs live url)
I thought this would work:
<a href="https://www.facebook.com/plugins/registration.php?client_id=98493fakenumber239&redirect_uri=settings.SITE_URL+"social_login/facebook/&fields=%5B%7B%22name%22%3A%22name%22%2C%22view%22%3A%22prefilled%22%7D%2C%7B%22name%22%3A%22first_name%22%7D%2C%7B%22name%22%3A%22last_name%22%7D%2C%7B%22name%22%3A%22email%22%7D%2C%7B%22name%22%3A%22password%22%7D%5D" class="facebook"></a>
Any ideas? Your help is very much appreciated.
Just use
{{ request.get_host }}in your code where you want the current domain. (Assumes you’re usingcontext_instance=RequestContext(request), Django 1.3’srendermethod, or class-based views).UPDATE
Seems Facebook only allows communication from the domain specified in your app’s settings. So, simply telling it to redirect to localhost isn’t good enough. It’ll simply give you the error that you got. Your best bet is likely going to be editing your hosts file on your local machine and adding an entry like:
In *nix environments (OSX, Ubuntu, etc.), you’ll find the hosts file at
/etc/hosts. In Windows it’s atC:\Windows\System32\drivers\etc\hosts.This will route all requests to the domain from your local machine back to your local machine. Obviously, you’ll then need to remove this from your hosts file after development to be able to access your production site.