17👍
For later versions of django_registration (that use class-based views), you can do this:
from registration.forms import RegistrationFormUniqueEmail
from registration.backends.default.views import RegistrationView
urlpatterns = patterns('',
url(r'^register/$',
RegistrationView.as_view(form_class=RegistrationFormUniqueEmail),
name='registration_register'),
)
13👍
from rych’s answer, I tested that the following runs ok – it only uses urls.py, you needn’t write another cusotmer form.
from registration.forms import RegistrationFormUniqueEmail
url(r'^accounts/register/$', 'registration.views.register',
{'form_class': RegistrationFormUniqueEmail,
'backend': 'registration.backends.default.DefaultBackend'},
name='registration_register'),
5👍
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
- Django: logging only for my project's apps
- External django redirect with POST parameters
- Django vs. Pylons
4👍
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))
- Django Queryset of related objects, after prefiltering on original model
- How can I make SSE with Python (Django)?
- CSV file upload from buffer to S3
- Does a library to prevent duplicate form submissions exist for django?
4👍
As miku pointed out, you should simply use RegistrationFormUniqueEmail .
If you implement according to the documentation and bug report replies (as of mid-2011),
you’ll probably end up with an exception like:
TypeError at /accounts/register/
register() takes at least 2 non-keyword arguments (1 given)
your urlconf should look like this to properly specify this backend:
(r'^accounts/register/', 'registration.views.register' {'form_class':RegistrationFormUniqueEmail, 'backend':'registration.backends.default.DefaultBackend' }),
(r'^accounts/', include('registration.backends.default.urls')),
[ please excuse the additional answer, as this belongs as a comment to miku’s correct answer; I don’t have the privilege of commenting, but this tip may save at least a few people 15 minutes each, so is hopefully worth the forced faux-pas ]
- How to set settings.LOGIN_URL to a view function name in Django 1.5+
- Getting file extension in Django template
2👍
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.
1👍
For unique e-mail addresses in django-registration-redux 1.4.
In url.py add following
from registration.forms import RegistrationFormUniqueEmail from registration.backends.default.views import RegistrationView urlpatterns = [ url(r'^accounts/register/$',RegistrationView.as_view(form_class=RegistrationFormUniqueEmail), name='registration_register'), url(r'^accounts/', include('registration.backends.default.urls')) ]
- Using Django view variables inside templates
- Django-tastypie: Any example on file upload in POST?
- Sphinx and re-usable Django apps
0👍
As of django-registration 3.1.2, I was able to solve this in an almost identical way as https://stackoverflow.com/a/19383392/10987661:
from django_registration.forms import RegistrationFormUniqueEmail
from django_registration.backends.activation.views import RegistrationView
urlpatterns = [
...
path('accounts/register/',
RegistrationView.as_view(
form_class=RegistrationFormUniqueEmail
),
name='django_registration_register',
),
path('accounts/', include('django_registration.backends.activation.urls')),
...
]
- Django – Overriding get_form to customize admin forms based on request
- Error installing mysqlclient for python on Ubuntu 18.04
- Python Django custom template tags register.assignment_tag not working
- How to have a nested inline formset within a form in Django?