Skip to content

Commit

Permalink
Added model kwarg to SignupView.create_user
Browse files Browse the repository at this point in the history
Enables sign up for complex user hierarchies. Overriding SignupView
can now dictate the User model through a code path with request
access.

Fixes #188
  • Loading branch information
brosner committed Dec 9, 2015
1 parent e615f10 commit 0747a12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* added Python 3.5 and Django 1.9 compatibility
* added Japanese translations
* added model kwarg to SignupView.create_user enabling sign up for complex user hierarchies

## 1.2.0

Expand Down
7 changes: 5 additions & 2 deletions account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ def get_success_url(self, fallback_url=None, **kwargs):
def get_redirect_field_name(self):
return self.redirect_field_name

def create_user(self, form, commit=True, **kwargs):
user = get_user_model()(**kwargs)
def create_user(self, form, commit=True, model=None, **kwargs):
User = model
if User is None:
User = get_user_model()
user = User(**kwargs)
username = form.cleaned_data.get("username")
if username is None:
username = self.generate_username(form)
Expand Down

0 comments on commit 0747a12

Please sign in to comment.