In your views.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from django.http import HttpResponse
from projectname import settings
from urllib import urlencode

def index(request):
params = {
'client_id': settings.FACEBOOK_APP_ID,
'redirect_uri': 'https://www.facebook.com/yourappname/app_' + settings.FACEBOOK_APP_ID,
'scope': 'email,user_birthday,offline_access,publish_stream',
}
redirect_url = 'https://www.facebook.com/dialog/oauth/?' + urlencode(params)
redirect_code = """
<script type="text/javascript">
top.location.href = '%s';
</script>
""" % redirect_url;

return HttpResponse(redirect_code, mimetype='text/html')

Make sure you add Facebook details to projectname/settings.py

1
2
3
...
FACEBOOK_APP_ID = '12332358235'
FACEBOOK_APP_SECRET = '2839fsd9fh29hg897eyr8g'

One more thing, be sure in your facebook app setting Website with Facebook Login set to your app URL

facebook setting

Hurray! You’ve done

References: