Pages

Wednesday, February 02, 2011

Using django registration on django non rel

On my journery to learn django non-rel and app engine, I could make django registration work on GAE. I did not have to change anything in the source, except few tweaks suggested by posts from django non-rel team on google groups. Please refer my reading list.

This exercise was quite interesting as it introduced me to new concepts such as csrf and I18N.

There are many tutorials over the internet on django-registration, however I was a little confused.. Which one should I try first?. Then I homed on to few (list) and decided to go for it.

These are the steps which I followed.

1. cloned django-registration to any directory ( in our case we made it in django-nonrel )

2. Arranging the templates
django-registration does not provide you with default templates, therefore we have to make our own. I downloaded them from here.3. I created the registration directory under templates directory

mkdir projectroot/templates/registration

and copied all downloaded html templates in the templates/registration directory

4. Making an additional template
The source for template did not have one (registration/activation_complete.html)
therefore I created one
activation_complete.html
Just make a copy of registration_complete.html and save it as activation_complete.html
Then I saved the template in the templates/registration directory

5. Accommodating to html Templates
You need to take care of 02 things in the templates.
a) crsf tags are not there in templates, go one by one in all templates, whereever you see form POST requests include csrf tokens '{% csrf_token %}'
b) These templates inherit the contents of base.html so I made a change in my base.html and included the div (id=header , from base.html from the downloaded templates), You can replace your base.html with the downloaded one.
c) ensure that all your templates have '{% load i18n %}' tags for internationalization6. Modified Settings.py
I modified my settings.py as below
a) included an import from djangoappengine