django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
34 stars 30 forks source link

Issue with user models which don't have a username #292

Closed marksweb closed 1 year ago

marksweb commented 2 years ago

We've got a queryset in ExtendedVersionAdminMixin which expects the User to have a username, but I've got a User model that uses email to login and doesn't include a username field.

def get_queryset(self, request):
        queryset = super().get_queryset(request)
        # Due to django admin ordering using unicode, to alphabetically order regardless of case, we must
        # annotate the queryset, with the usernames all lower case, and then order based on that!
        queryset = queryset.annotate(created_by_username_ordering=Lower("versions__created_by__username"))
        return queryset

https://github.com/django-cms/djangocms-versioning/blob/master/djangocms_versioning/admin.py#L136

So this is throwing an error from djangocms-alias

fsbraun commented 1 year ago

Fixed by #293