Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4235252
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:28:20+00:00 2026-05-21T02:28:20+00:00

I have implemented a Django app having a user login/registration page. I wanted to

  • 0

I have implemented a Django app having a user login/registration page. I wanted to make facebook user id’s also possible for logging into my app. In doing so, i followed this link http://developers.facebook.com/docs/guides/web/#login . With the help of that link i can now login using the Facebook id also. Clicking on the facebook login button, pop ups with a facebook login page; giving the username n passw, makes it logged in with facebook. But after logging in also the page is redirected back to my home page. I need to redirect it to some other url, say http://localhost/login/ . Can somebody help me to solve this. I will paste my html part used for django login.

html

<body>
     <div id="fb-root"></div>
      <script src="http://connect.facebook.net/en_US/all.js"></script>
      <script>
         FB.init({ 
            appId:'114322105313139', cookie:true,
            status:true, xfbml:true 
         });
      </script>


  <fb:login-button>Login with Facebook</fb:login-button>

</body>

settings.py

# Django settings for universityDB project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'student',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'qburst',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}


EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = '587'
EMAIL_HOST_USER = "rv@gmail.com" #create a gmail id
EMAIL_HOST_PASSWORD = "xxxx"#pwd for that id
EMAIL_USE_TLS = True 


FACEBOOK_CACHE_TIMEOUT=1800
FACEBOOK_APP_ID='xxx'
FACEBOOK_API_KEY='xxx'
FACEBOOK_SECRET_KEY='xxxx'
FACEBOOK_INTERNAL = 'TRUE'


# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'b_3=te)1b57mqsz^))jg95i%umw=*pug_i*8j!$6@y4(ie=8x$'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
     'django.middleware.csrf.CsrfResponseMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'facebook.djangofb.FacebookMiddleware',
    'facebookconnect.middleware.FacebookConnectMiddleware',
   # 'facebook.djangofb.FacebookMiddleware',
   # 'socialregistration.middleware.FacebookMiddleware' ,    

)


AUTHENTICATION_BACKENDS = (
    'facebookconnect.models.FacebookBackend',
    'social_auth.backends.facebook.FacebookBackend',
    'django.contrib.auth.backends.ModelBackend',
)



LOGIN_URL          = '/login-form/'
LOGIN_REDIRECT_URL = '/logged-in/'
LOGIN_ERROR_URL    = '/login-error/'

SOCIAL_AUTH_ERROR_KEY = 'social_errors'

SOCIAL_AUTH_COMPLETE_URL_NAME  = 'complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'associate_complete'

SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'

SOCIAL_AUTH_EXTRA_DATA = False

SOCIAL_AUTH_EXPIRATION = 'expires'

SOCIAL_AUTH_SESSION_EXPIRATION = False


DUMMY_FACEBOOK_INFO = {
    'uid':0,
    'name':'(Private)',
    'first_name':'(Private)',
    'pic_square_with_logo':'http://www.facebook.com/pics/t_silhouette.gif',
    'affiliations':None,
    'status':None,
    'proxied_email':None,
}

ROOT_URLCONF = 'universityDB.urls'

TEMPLATE_DIRS = (
    "/home/Desktop/universityDB/templates"             
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'universityDetails',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    'captcha',
    'facebookconnect',
    'social_auth',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:28:21+00:00Added an answer on May 21, 2026 at 2:28 am

    That code just looks like FB’s HTML. You’d need to give us a better idea of your Django Auth structure if you wanted more help.

    There are quite a few more steps ahead of you. I would look into Django-SocialAuth for an easily integrated experience if I were you.

    Edit:
    As a follow up to the inclusion of your Settings.py, assuming that you’ve read the Facebook Authentication docs as well as the SocialAuth README, you will need to set up the appropriate controller for fb’s authentication callback url.

    After that, hook these SocialAuth views into your current authentication process:

    def facebook_login(request):
        """
        Facebook login page
        """
        if request.REQUEST.get("device"):
            device = request.REQUEST.get("device")
        else:
            device = "user-agent"
    
        params = {}
        params["client_id"] = FACEBOOK_APP_ID
        params["redirect_uri"] = request.build_absolute_uri(reverse("socialauth_facebook_login_done"))
    
        url = "https://graph.facebook.com/oauth/authorize?"+urllib.urlencode(params)
    
        return HttpResponseRedirect(url)
    
    def facebook_login_done(request):
        user = authenticate(request=request)
    
        if not user:
            request.COOKIES.pop(FACEBOOK_API_KEY + '_session_key', None)
            request.COOKIES.pop(FACEBOOK_API_KEY + '_user', None)
    
            # TODO: maybe the project has its own login page?
            logging.debug("SOCIALAUTH: Couldn't authenticate user with Django, redirecting to Login page")
            return HttpResponseRedirect(reverse('socialauth_login_page'))
    
        login(request, user)
    
        logging.debug("SOCIALAUTH: Successfully logged in with Facebook!")
    
        if request.GET.get('next'):
            return HttpResponseRedirect(request.GET.get('next'))
        else:
            return HttpResponseRedirect(LOGIN_REDIRECT_URL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a django app. I have implemented a facebook login along with
I have implemented a registration/login/authentication system using this Django guide . But, how would
I have a strange issue here with my Django app. I implemented the user
I have created a Django app. I have a registration page(simple HTML form) in
I created a django application with a user login/registration page. I am trying to
I have a django app that I made and have implemented a plist into
I have implemented Facebook into my app but now I find that whenever I
I am building a django app as part of it I have a page
I'm trying to implement django-filebrowser into my latest app. I have grappelli installed also.
I have a Django app. When logged in as an admin user, I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.