Reusable recaptcha comments app
Sat 03 January 2009 by Thejaswi PuthrayaReusable recaptcha comments app
One aim of Jacob's code for the comments framework in Django 1.0 was to make it as extensible as possible. At the same time this process should be quite generic and as DRY as possible.
It is here that I worked for a very long time but in last minute goof-ups could not push these changes to be included in 1.0.
Well anyways, I opened a ticket quick enough so that this feature didn't fade off with time. I attached an initial patch and soon there was a lot of activity and within no time people contributed tests and docs for the patches. I want to thank all those people who contributed or are interested in the ticket. Luckily this ticket will be in trunk by 1.1 championed by Jacob himself (See roadmap).
So in this blog post I announce a reusable app called recaptcha-django-comments It is a very simple app that appends a Recaptcha field to the comment form.
Procedure to use it
Fetch the source from here and place the recaptcha_comments app in your django project.
Patch your django source with the latest patch from #8630.
Update the INSTALLED_APPS in the settings.py to reflect this app.
Add the following attributes in the settings.py.
COMMENTS_APP = "recaptcha_comments" RECAPTCHA_PUBLIC_KEY = "xyz....." RECAPTCHA_PRIVATE_KEY = "abc...."Add the following middleware to the settings.py. It will help pass on the IP Address to recaptcha if you are behind a reverse proxy. This step is not required if you are not behind a reverse proxy.
MIDDLEWARE_CLASSES= ('...', 'django.middleware.http.SetRemoteAddrFromForwardedFor', )Copy the comments/ directory from recaptcha_comments/templates into your templates directory as referenced by your settings.py.
Edit the project's urls.py to have the following line.
(r'^comments/', include('recaptcha_comments.urls')),
That's it!!!
Well, the toughest part in the procedure is to patch the django source (by difficult I mean the decision to patch django).
Please let me know your opinions about this app.
Stay tuned for more and oops I forgot...**HAPPY NEW YEAR**!!!