I am trying to make signup form using django-registration app. But, when I submit registration form I get message "Server Error (500)"? Please, help me - what I do wrong?
templates/registration/registration_form.html:
<form method="post" action="">{% csrf_token %}
<dl class="register">
{% for field in form %}
<dt>{{ field.label_tag }}</dt>
<dd class="clearfix">{{ field }}
{% if field.help_text %}<div class="clearfix">{{ field.help_text }}</div>{% endif %}
{% if field.errors %}<div class="myerrors clearfix">{{ field.errors }}</div>{% endif %}
</dd>
{% endfor %}
</dl>
<input type="submit" value="Register" / class="clearfix">
</form>
urls.py:
url(r'^accounts/', include('registration.backends.default.urls')),
I ran smtp server for testing of mail sending:
python -m smtpd -n -c DebuggingServer localhost:1025
There are no message with email at console
settings.py:
ACCOUNT_ACTIVATION_DAYS = 2 #
AUTH_USER_EMAIL_UNIQUE = True
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'info@google.ru'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'registration',
)
I created templates:
1.activation_email_subject.txt
Activation – {{ site }}
2.activation_email.txt
Follow {{ site }}/accounts/activate/{{ activation_key }}/
3.activate.html
Activated. <a href="{% url auth_login %}">Login</a> to site.
4.activation_email_subject.txt
Activation – {{ site }}
5.login.html
...
6.activation_complete.html
activation_complete
7.activation_email_subject.txt
Activation – {{ site }}
8.registration_complete.html
Complete
9.logout.html
...
Traceback Switch to copy-and-paste view
/home/bo858585/.env/local/lib/python2.7/site-packages/django/core/handlers/base.py in get_response
response = callback(request, *callback_args, **callback_kwargs)
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/views/generic/base.py in view
return self.dispatch(request, *args, **kwargs)
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/registration/views.py in dispatch
return super(RegistrationView, self).dispatch(request, *args, **kwargs)
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/views/generic/base.py in dispatch
return handler(request, *args, **kwargs)
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/registration/views.py in post
if form.is_valid():
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/forms/forms.py in is_valid
return self.is_bound and not bool(self.errors)
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/forms/forms.py in _get_errors
self.full_clean()
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/forms/forms.py in full_clean
self._clean_fields()
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/forms/forms.py in _clean_fields
value = getattr(self, 'clean_%s' % name)()
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/registration/forms.py in clean_username
existing = User.objects.filter(username__iexact=self.cleaned_data['username'])
...
▶ Local vars
/home/bo858585/.env/local/lib/python2.7/site-packages/django/db/models/manager.py in __get__
self.model._meta.object_name, self.model._meta.swapped
...
▶ Local vars
It looks like you swapped the default auth.User
for a custom users.User
.
if you want to use django-registration with a custom User
class, you need to use a custom registration form, too. From the source code:
Note that all of these forms assume Django's bundle default
User
model; since it's not possible for a form to anticipate in advance the needs of custom user models, you will need to write your own forms if you're using a custom model.
You need to re-implement the registration form for your custom User
and tell django-registration to use it (set the form_class
attribute on your registration view)