Archive for June, 2006

Django “forgot your password”

Sunday, June 18th, 2006

Django has a nice but hidden Password reset feature. To use it, you have to uncomment the “forgotten your password?” link in the login form. This patch is an example how to do it.

Than you have to activate it in your main urls.py like this:

(r'^password_reset/$',     'django.contrib.auth.views.password_reset'),
(r'^password_reset/done/$','django.contrib.auth.views.password_reset_done'),

You’re basically set here, although there are still some rough edges. One thing is that the emails sent out with the new password have some issues. One is variable substitutiuon -this patch (Ticket #2186) fixes it.

Another issue are that unwanted links might creep on your “password successfully reset” page. This patch fixes this issue.

Django comments

Tuesday, June 13th, 2006

Django contains a wonderful comment framework. It is underdocumented but very nice. You can see it at work on the Django Website where it powers the comments function on many of the pages.

When you post a comment, the comment framework provides you with a “thank you for your comment, back to the original page” webpage. One thing I was missing there is that the “back to the original page” uses an anchor tag to link to the position of the new comment on the original page.

This patch provides this ability. It is Ticket #2134 at the django trac.

Fixing display of redirects in the admin interface

Tuesday, June 13th, 2006

This tiny patch makes redirects in the magic-removal admin interface of django look nice as they did in pre magic-removal times.

It’s Ticket #2139 at django and has been fixed in Changeset 3122.

All static typed languages are broken

Wednesday, June 7th, 2006

Joshua Bloch, Software Engineer at Google Research recently wrote about the non-correctness of ALL mergesort implementations. His statement stands on the tottery shoulders of static typed languages. Joshua, get a decent programming language and don’t tell non-sense!

Reminds me of a nice quote.

Generating PDFs in Django

Sunday, June 4th, 2006

Try a view like this to get PDFs out of Django:

from reportlab.pdfgen.canvas import Canvas

def fixplatzfahnen(request):
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'inline; filename=fixplatzfahnen.pdf'

pdf = Canvas(response)
pdf.drawString(10, 10, "TEST")
pdf.showPage()
pdf.save()
return response