`
Sep 17

Django has been my thing for the past few weeks. It’s been a lot of fun reading the James Bennett’s practical-django-projects[1]Practical Django Projects. Unfortunately, on Sept 3, the release of Django v1.0 has made many of the codes not compatible.

The new release of Django has given me a headache while I was trying to setup django-registration. The problem lies in the upgrading of Django to the latest build. The old Django codes cause a problem in setting the app. Thanks to the guys at the Django Channel that helped me out.

So I hope I can help by writing a tutorial for those who needs it. Stone Mind, once wrote a tutorial on django-registration, but it’s out-dated now.

Here it goes:

Prerequisites:
django version 1.0
django-registration version 0.6 (if possible, use the trunk copy)

Step 1, unpack django-registration:
Put the app folder, registration into the project folder. (make sure that your PYTHONPATH is pointing to the project folder). registration folder is the folder that contains __init__.py.

Step 2, setup the application:
Add ‘registration’ into the list of INSTALLED_APPS. For example,

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'registration',
)

Step 3, setup the database:
Run python manage.py syncdb to populate the tables from the list of applications. Ensure you have filled in the relevant database settings before you run it. Example for sqlite3 database settings,

DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'reg.db'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

Step 4, setup the url pointer:
Add (r'accounts/', include('registration.urls')) into the list of URLpatterns. For example,

urlpatterns = patterns('',
    (r'^admin/(.*)', admin.site.root),
    (r'^accounts/', include('registration.urls')),
)

Step 5, setup the templates:
Setup the template path by adding /path/to/project/templates/ in TEMPLATE_DIRS. Example,

TEMPLATE_DIRS = (
   '/Users/mangoorange/Projects/Django/reg/templates/'
)

Step 6, inserting the templates:
This part is actually fairly simple. I have provided a copy of a working project, [download#74#nohits], that you can use. Just add in the django-registration app into the project folder. If you want to learn more about template form, you can check it out here.

Step 7, done:
Sorry to disappoint you. It’s done. 🙂

Feel free to share any feedback and comments on the tutorial. Hope it helps.

written by mangoorange \\ tags: , ,


Best Wordpress Hosting Providers - 2014

All three hosts offer FREE 1-click Wordpress installs making them the best Wordpress hosting providers. For more web hosting reviews be sure to check out AlreadyHosting.com.

 #1
#2 
 #3
#1 - Bluehost 
Bluehost Review
#2 - iPage 
iPage Review
#3 - HostMetro 
HostMetro Review

One Ping to “django-registration tutorial”

  1. Django IA: Registration-Activation « streamhacker.com Says:

    […] basic idea is that an anonymous user can create a new account, but cannot login until they activate their […]


6 Responses to “django-registration tutorial”

  1. 1. mickeyckm Says:

    @Sergio: You can try using django-profiles to fill in other information.

  2. 2. bought_the_book Says:

    I agree — I have all the django books — I went through a lot of headaches only to realize that if you follow the directions and use the latest version of django that a lot of the code that they say works is totally obsolete making the books near worthless —

    and if you buy the teach yourself django in 24 hours . . . you’ll be spending a lot more that 24 hours trying to figure out what’s going on and why the tutorials do not work.

  3. 3. 3cm Says:

    Where exactly do I place the registration directory?

    My application is located in home/webapps/django/myproject/myapp.

    Thanks.

  4. 4. Cody Says:

    thanks a kabillion

  5. 5. simon Says:

    Many thanks, works like a dream..
    To customise admin templates used by registration checkout this article:
    http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/

  6. 6. Andrew B. Says:

    Thanks! Your templates are a great starting point. I don’t know why django-registration doesn’t include examples.

Leave a Reply

You must be logged in to post a comment.