Adding support for custom user models (with fixes) #2753

Merged
merged 66 commits into from Feb 28, 2014

Conversation

Projects
None yet
6 participants
Contributor

koirikivi commented Feb 27, 2014

This PR incorporates the hard work done by @tanderegg, @itsnotworking and @stefanfoulis with a couple of last minute fixes of mine, as discussed in divio/django-cms#2622. Thanks so much for your effort.

Travis CI already passes for my local fork, see https://travis-ci.org/koirikivi/django-cms/builds/19692711.

stefanfoulis and others added some commits May 19, 2013

Fixed tests to support specifying user model on the command line, and…
… custom models that do not have a username field, or use email as username field
Contributor

hcNick commented Feb 27, 2014

Amazing work. Thanks!

Is there nothing about this in the docs?

Owner

koirikivi replied Feb 27, 2014

@digi604: This is just a hack to avoid circular imports as outlined in 96c770d. Or is the ImproperlyConfigured an issue?

docs/getting_started/configuration.rst
+
+DjangoCMS expects a user model with at minimum the following fields: email, password, first_name, last_name, is_active, is_staff, and is_superuser. Additionally, it should inherit from AbstractBaseUser and PermissionsMixin (or AbstractUser), and must define one field as the USERNAME_FIELD (see Django documentation for more details).
+
+Lastly, your custom user model must be named "User" in order to support reverse relationships with the Group model and other models.
@digi604

digi604 Feb 27, 2014

Contributor

If this is really not needed remove it here.

Contributor

tanderegg commented Feb 27, 2014

It still is needed due to reverse relationship naming conventions with the Group model, but I'm in the process of addressing that problem now. I'll merge @koirikivi's PR into mine, and update mine shortly.

Contributor

koirikivi commented Feb 27, 2014

All right, thanks :)

Contributor

tanderegg commented Feb 27, 2014

I've incorporated these changes into #2622, and added some additional modifications that were required to fully support custom naming of custom user models.

Coverage Status

Coverage increased (+0.01%) when pulling 2df0bea on koirikivi:develop into 3a09d5c on divio:develop.

Support both Django 1.5 and 1.6 with custom-named user Models
Django 1.5 expects Group.customusername_set, but Django 1.6 expects
Group.user_set. Define cms.compat.user_related_name and
cms.compat.user_related_query_name to reflect this.

Coverage Status

Coverage increased (+0.02%) when pulling 84b006c on koirikivi:develop into 3a09d5c on divio:develop.

Contributor

koirikivi commented Feb 28, 2014

Fixed Django 1.5 and 1.6 support for custom-named user models and python 3 import errors in tests. Should be ready to merge once tests pass.

Coverage Status

Coverage increased (+0.02%) when pulling 1d361ad on koirikivi:develop into 3a09d5c on divio:develop.

digi604 added a commit that referenced this pull request Feb 28, 2014

Merge pull request #2753 from koirikivi/develop
Adding support for custom user models (with fixes)

@digi604 digi604 merged commit 168d276 into divio:develop Feb 28, 2014

1 check passed

default The Travis CI build passed
Details
Contributor

digi604 commented Feb 28, 2014

thnx for the hard work guys

Contributor

tanderegg commented Feb 28, 2014

Thanks @koirikivi, I should have tested with all versions of Django first :) Good solution!

Contributor

koirikivi commented Feb 28, 2014

@tanderegg thanks to you for your efforts! I'm already using this in a real-life project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment