<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=338168267432629&amp;ev=PageView&amp;noscript=1">
Programming

Going Beyond Django’s Registration

Here’s a Django tutorial on registration. Registration allows you to have users. A weak registration system puts your site at risk of spammers getting in. A good registration system takes time to set up, even with the current handlers that Django has in place – while the basic functionality is …


{%- set hs_blog_post_body -%} {%- set in_blog_post_body = true -%}

Here’s a Django tutorial on registration. Registration allows you to have users. A weak registration system puts your site at risk of spammers getting in. A good registration system takes time to set up, even with the current handlers that Django has in place – while the basic functionality is already supported, such as sending emails, authentication, and user information storage, these functions are spread apart, and must still be lumped together by the django user.

Considering that a general system is truly necessary, it’s not surprising that the community has come up with django-registration.

Django registration provides all the basic necessities for making a good registration system for your site, from signup, email activation, and eventual login.

Installation

(0.8 alpha)

pip install hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registation

(0.7 build, not the tutorial followed here)

pip install django-registration

Then as usual, include in your INSTALLED_APPS

# settings.py

INSTALLED_APPS = ( ...auth, ...sites, 'registration' )

and define this constant

ACCOUNT_ACTIVATION_DAYS = 7 #number of days you want the activation to be valid

You also need to modify your urls.py to include the registration views,

# urls.py

...other patterns...


 
 

(r'^accounts/', include('registration.backends.default.urls')),

Others

==== Setting up Email ====

http://docs.djangoproject.com/en/dev/topics/email/

==== templates ====

The user (you) will have to provide templates with the names specified by django-registration. Note that django-registration will not work without these templates/files.

==== Site Templates ====

  • registration/registration_form.html
  • registration/registration_complete.html
  • registration/activate.html
  • registration/activation_complete.html

==== Email Construction Templates ====

  • registration/activation_email_subject.txt
  • registration/activation_email.txt

Summary

It’s a shame that default basic templates weren’t provided, but with everything else that this system gets done, it’s a small price to pay.

(For reference, here is the template I made to test signing up.

<!-- registration/registration_form.html -->

{% extends "registration/base.html" %}

{% block content %}

    this is the basic form:

    <div>

    <form action='.' method='POST'>

        {{ form.non_field_errors }}

        {% for field in form %}

            <div>

            {% if field.errors %} {{ field.errors }} {% endif %}

                {{field.label }}  {{ field }}

            </div>

        {% endfor %}

        <input type="submit" value="Submit">

    </form>

    </div>

{% endblock %}

 

{%- endset -%} {%- set hs_blog_post_summary -%}

Here’s a Django tutorial on registration. Registration allows you to have users. A weak registration system puts your site at risk of spammers getting in. A good registration system takes time to set up, even with the current handlers that Django has in place – while the basic functionality is already supported, such as sending emails, authentication, and user information storage, these functions are spread apart, and must still be lumped together by the django user.

Considering that a general system is truly necessary, it’s not surprising that the community has come up with django-registration.

Django registration provides all the basic necessities for making a good registration system for your site, from signup, email activation, and eventual login.

Installation

(0.8 alpha)

pip install hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registation

(0.7 build, not the tutorial followed here)

pip install django-registration

Then as usual, include in your INSTALLED_APPS

# settings.py

INSTALLED_APPS = ( ...auth, ...sites, 'registration' )

and define this constant

ACCOUNT_ACTIVATION_DAYS = 7 #number of days you want the activation to be valid

You also need to modify your urls.py to include the registration views,

# urls.py

...other patterns...


 
 
{%- endset -%} {%- blog_post_data_wall_wrapper body={{hs_blog_post_body}}, summary={{hs_blog_post_summary}} %}

Similar posts

Get notified about the latest in Tech

Be the first to know about new tech from the experts at Bixly!