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.
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**!!!
Hi, This is great work. Can you please clarify : Will this work with django 1.0.2 or I have to 'Patch your django source with the latest patch from #8630.'? Thanks, Prem btw, please dont ask for Url! not everyone has one to give.
@prem: You will have to patch it for django 1.0.2. I would recommend you upgrade to 1.1 for a lot of other larger goodies! About the URL, you can leave your twitter, facebook or whatever 'vanity' url you wish. If you want to be completely anonymous, the good old http://www.example.com/ always works!
Thejaswi Puthraya commented on 3rd January 2009 07:52
To demo this feature, comment here ;-)