Skip to content
Snippets Groups Projects
Commit a3993edf authored by Calum Mackervoy's avatar Calum Mackervoy
Browse files

feature: added REGISTRATION_USER_FORM setting

parent b63ac1c7
No related branches found
No related tags found
1 merge request!99feature: added REGISTRATION_USER_FORM setting
Pipeline #12941 passed
...@@ -66,9 +66,15 @@ Optionally you can configure which user fields which you would like to include o ...@@ -66,9 +66,15 @@ Optionally you can configure which user fields which you would like to include o
REGISTRATION_FIELDS = ('username', 'email', 'password1', 'password2') REGISTRATION_FIELDS = ('username', 'email', 'password1', 'password2')
``` ```
The workflow starts at : http://127.0.0.1:8000/accounts/register/ This will be sufficient to change the user fields on display on the form. If you want to customise the form (for example by [adding a model relationship to the user](https://stackoverflow.com/questions/14726725/python-django-django-registration-add-an-extra-field/14879316#14879316)), then you can override the setting `REGISTRATION_USER_FORM` to replace it altogether. The form you supply should extend `djangoldp_account.forms.LDPUserForm` or at minimum `django_registration.forms.RegistrationForm`
Then, override template by copying the directory `djangoldp_account/templates/django_registration/` to your project and modify them. ```
REGISTRATION_USER_FORM: "djangoldp_hiphopcommunity.forms.HipHopUserForm"
```
In either case, at a minimum the registration form fields must include the fields `('username', 'email', 'password1', 'password2')`
Visit http://127.0.0.1:8000/auth/register/ to access the registration form
### Enabling account activation without mail ### Enabling account activation without mail
......
"""djangoldp project URL Configuration""" """djangoldp project URL Configuration"""
from pydoc import locate
from django.conf import settings from django.conf import settings
from django.conf.urls import url, include from django.conf.urls import url, include
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
...@@ -17,6 +18,9 @@ Group._meta.anonymous_perms = getattr(settings, 'GROUP_ANONYMOUS_PERMISSIONS', [ ...@@ -17,6 +18,9 @@ Group._meta.anonymous_perms = getattr(settings, 'GROUP_ANONYMOUS_PERMISSIONS', [
Group._meta.authenticated_perms = getattr(settings, 'GROUP_AUTHENTICATED_PERMISSIONS', ['inherit']) Group._meta.authenticated_perms = getattr(settings, 'GROUP_AUTHENTICATED_PERMISSIONS', ['inherit'])
Group._meta.owner_perms = getattr(settings, 'GROUP_OWNER_PERMISSIONS', ['inherit']) Group._meta.owner_perms = getattr(settings, 'GROUP_OWNER_PERMISSIONS', ['inherit'])
user_form_override = getattr(settings, 'REGISTRATION_USER_FORM', None)
user_form = LDPUserForm if user_form_override is None else locate(user_form_override)
urlpatterns = [ urlpatterns = [
url(r'^groups/', url(r'^groups/',
LDPViewSet.urls(model=Group, fields=['@id', 'name', 'user_set'], LDPViewSet.urls(model=Group, fields=['@id', 'name', 'user_set'],
...@@ -25,7 +29,7 @@ urlpatterns = [ ...@@ -25,7 +29,7 @@ urlpatterns = [
), ),
url(r'^auth/register/$', url(r'^auth/register/$',
LDPAccountRegistrationView.as_view( LDPAccountRegistrationView.as_view(
form_class=LDPUserForm form_class=user_form
), ),
name='django_registration_register', name='django_registration_register',
), ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment