#29748: Add AUTH_GROUP_MODEL setting to swap the group model
------------------------------+-----------------------------------------
     Reporter:  damoncheng    |                    Owner:  damoncheng
         Type:  New feature   |                   Status:  assigned
    Component:  contrib.auth  |                  Version:  dev
     Severity:  Normal        |               Resolution:
     Keywords:                |             Triage Stage:  Someday/Maybe
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+-----------------------------------------

Comment (by Bernd Wechner):

 See: https://github.com/shacker/django-todo/pull/130

 If Django core developers express a willingness to see this coded, I'm
 willing to code it up and submit a PR.

 It's not hard and is needed for consistency with the
 {{{settings.AUTH_USER_MODEL}}} setting.

 It's not 100$ trivial as it means we'd need to add not only add:


 {{{
 def get_group_model():
     """
     Return the Group model that is active in this project.
     """
     try:
         return django_apps.get_model(settings.AUTH_GROUP_MODEL,
 require_ready=False)
     except ValueError:
         raise ImproperlyConfigured("AUTH_GROUP_MODEL must be of the form
 'app_label.model_name'")
     except LookupError:
         raise ImproperlyConfigured(
             "AUTH_GROUP_MODEL refers to model '%s' that has not been
 installed" % settings.AUTH_GROUP_MODEL
         )
 }}}

 around about here:

 
https://github.com/django/django/blob/4ff500f2948bfc332b3f4159021cad06e91943d3/django/contrib/auth/__init__.py#L155

 but also we confront the fact that with configurable USER and GROUP models
 the relation between them is also perforce, configurable. We need only
 know that one exists (and can stipulate that it is to-many from USER to
 GROUP (by definition), and thus implement:

 {{{
 def user_group_field():
     find a field in get_user_model() that is a 2many relation to
 get_group_model() and return it
 }}}

 from that field the reverse field can also be fetched and we need:

 {{{
 def group_user_field():
     return the related_name for user_group_field()
 }}}


 So it's not **nothing** but it is rather trivial all the same, and I'm
 very to code it up, run the tests, PR it. But don't want to waste my time
 if it's not welcome. I could infer it's welcome from the triage three
 years ago to **Someday / Maybe**. But will fish here for some
 encouragement first.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29748#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.f038c94dec9d35a3b856cfb497e59171%40djangoproject.com.

Reply via email to