tags:

views:

75

answers:

2

Hi,

I'm a Django amateur, and have problems getting django-registration to work. I followed the installation instructions on their website, but for someone like me these instructions are not 100% clear as to what I should be doing. Here is what I've done:

  1. I installed the oauth2 and python-openid packages using pip. I then copied the facebook.py file from the facebook-python-sdk package to my main django app directory. (As I write this, I'm wondering whether this file should be copied to the socialregistration app directory? Does it make a difference?)
  2. I copied the socialregistration directory to my django project's directory.
  3. I added socialresgitration to my INSTALLED_APPS setting.
  4. To add socialregistration.urls to my urls.py file, I added the following line (not sure if this is correct, since the instructions don't give details):
    (r'^social/', include('socialregistration.urls')),
  5. I added the facebook API key and secret key to my settings
  6. I added socialregistration.auth.FacebookAuth to AUTHENTICATION_BACKENDS.
  7. I added socialregistration.middleware.FacebookMiddleware to MIDDLEWARE_CLASSES.
  8. Finally I added the three facebook tags they give in the instructions to one of my templates.
  9. When I then load my website, I get the folllowing error:
    Caught AttributeError while rendering: Please add the django.core.context_processors.request context processors to your settings.TEMPLATE_CONTEXT_PROCESSORS set

So, what can I do? I thought installation would be quite simple, but apparently this is not the case. ANY help would be appreciated!

Oh, BTW, I'm using Django 1.2.1 and Python 2.6.

Thanks!

A: 

Please add the django.core.context_processors.request context processors to your settings.

Have you done that?

You'll need to change TEMPLATE_CONTEXT_PROCESSORS to include django.core.context_processors.request.

Dominic Rodger
I tried that, but the same error still persists. I dug into the source code of the socialregistration app, and this is the part that is causing the error: if not 'request' in context: raise AttributeError, 'Please add the ``django.core.context_processors.request`` context processors to your settings.TEMPLATE_CONTEXT_PROCESSORS set'.I added the context processor to my main settings.py file. I assume this is the way to do it? Not sure what else it could be... :(
Helmut
@Helmut - post the full `TEMPLATE_CONTEXT_PROCESSORS` setting.
Dominic Rodger
TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.contrib.messages.context_processors.messages", "django.core.context_processors.request",)
Helmut
+1  A: 

I've found the problem. When my view renders the template, it needs to pass the RequestContext to the template.

return render_to_response('my_template.html', my_data_dictionary, context_instance=RequestContext(request))

Source: http://lincolnloop.com/blog/2008/may/10/getting-requestcontext-your-templates/

Helmut
It is, however, still necessary to add the context processorbove to the settings.
Helmut