Commit 86474e60 authored by Calum Mackervoy's avatar Calum Mackervoy Committed by Jean-Baptiste Pasquier

Configurable fields in Registration form

parent a7584d46
...@@ -59,6 +59,11 @@ EMAIL_HOST_PASSWORD = 'password' ...@@ -59,6 +59,11 @@ EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587 EMAIL_PORT = 587
``` ```
Optionally you can configure which user fields which you would like to include on the registration form by including `REGISTRATION_FIELDS` in settings.py
```python
REGISTRATION_FIELDS = ('username', 'email', 'password1', 'password2')
```
The workflow starts at : http://127.0.0.1:8000/accounts/register/ The workflow starts at : http://127.0.0.1:8000/accounts/register/
Then, override template by copying the directory `djangoldp_account/templates/django_registration/` to your project and modify them. Then, override template by copying the directory `djangoldp_account/templates/django_registration/` to your project and modify them.
......
...@@ -4,6 +4,13 @@ from django_registration.forms import RegistrationForm ...@@ -4,6 +4,13 @@ from django_registration.forms import RegistrationForm
from djangoldp_account.models import LDPUser from djangoldp_account.models import LDPUser
def _get_user_form_fields():
'''Gets the fields required for the form from settings, or returns default'''
from django.conf import settings
return getattr(settings, 'REGISTRATION_FIELDS', ('username', 'email', 'password1', 'password2'))
class LDPUserForm(RegistrationForm): class LDPUserForm(RegistrationForm):
class Meta(RegistrationForm.Meta): class Meta(RegistrationForm.Meta):
model = get_user_model() model = get_user_model()
fields = _get_user_form_fields()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment