Skip to content

Commit

Permalink
Use username getter instead of accessing field directly
Browse files Browse the repository at this point in the history
This change adds support for custom user models without `username` field.

`username` field is not guaranteed in custom usermodels in django. 
Custom user models however can specify another field designated as a username via `USERNAME_FIELD`, whose value is always returned from `get_username()`

Should resolve issue #267
  • Loading branch information
mick88 committed Jun 17, 2016
1 parent 9f48923 commit 80ed3a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckeditor_uploader/views.py
Expand Up @@ -20,7 +20,7 @@
def get_upload_filename(upload_name, user):
# If CKEDITOR_RESTRICT_BY_USER is True upload file to user specific path.
if getattr(settings, 'CKEDITOR_RESTRICT_BY_USER', False):
user_path = user.username
user_path = user.get_username()
else:
user_path = ''

Expand Down Expand Up @@ -96,7 +96,7 @@ def get_image_files(user=None, path=''):

restrict = getattr(settings, 'CKEDITOR_RESTRICT_BY_USER', False)
if user and not user.is_superuser and restrict:
user_path = user.username
user_path = user.get_username()
else:
user_path = ''

Expand Down

0 comments on commit 80ed3a8

Please sign in to comment.