tags:

views:

415

answers:

3

Can I force users to make unique e-mail addresses in django-registration?

+1  A: 

It should suffice to create your registration form from your user model. If the e-mail address is defined to be unique there, the form will output an error on submit for duplicate addresses.

Look here for details.

As Dominic points out, you'll not be able to do this with the built-in user profile. You'll have to extend it by creating your own user profile as described here and make it contain a unique e-mail address.

jellybean
That doesn't help much when the model is one that is built-in... http://docs.djangoproject.com/en/dev/topics/auth/#fields
Dominic Rodger
but I want cause reaction like when user try to use nick which is in use - he gets AJAX error that nick is used - I want to do the same with e-mail.
DJPython
+2  A: 

django-registration has several forms included in the source – one is a RegistrationFormUniqueEmail, which might help you ...


P.S. You can adjust the form to use by changing the default backend or by implementing a custom one, where you return the appropriate form class, see: http://bitbucket.org/ubernostrum/django-registration/src/073835a4269f/registration/backends/default/init.py#cl-118

The MYYN
Do I have to have access to django-registration files? I've changed form_class in registration definition, and nothing happened. I don't have acces to installed django-registration files. Only for django-registration files instances in my app folder.
DJPython
I'm not sure about your setup, but I used to download the recent django-registration version into my projects directory, so I'm able to change files when needed (and I'm able to update the app, when needed). Also in my case, the above approach just works ...
The MYYN
A: 
forms.py

from registration.forms import RegistrationFormUniqueEmail

class RegistroPerfilForm(RegistrationFormUniqueEmail):
    first_name= forms.CharField(required=True)
    last_name= forms.CharField(required=True)
    kind__of_user= forms.CharField(widget=forms.RadioSelect(choices=TIPO))
Asinox