Quantcast

[Django] #18686: Models with same name and common subpackage name clash

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[Django] #18686: Models with same name and common subpackage name clash

Django
#18686: Models with same name and common subpackage name clash
----------------------------------------------+--------------------
     Reporter:  jason.yates@…                 |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 In the following example, Test is an empty model declared in both
 base/a/test/models.py and base/b/test/models2.py:

 {{{
 from base.a.test.models import Test
 from base.b.test.models2 import Test as Test2

 Test.__module__ # prints com.a.test.models
 Test2.__module__ # prints com.a.test.models, but should print
 base.b.test.models2
 }}}


 It appears that the commonly named 'test' subpackage in both 'base.a' and
 'base.b' is the issue. Renaming either subpackage causes the issue to
 disappear.


 {{{
 # models.py/models2.py
 from django.db import models
 class Test(models.Model): pass
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18686>
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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [Django] #18686: Models with same name and common subpackage name clash

Django
#18686: Models with same name and common subpackage name clash
-------------------------------------+-------------------------------------
     Reporter:  jason.yates@…        |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  1.3
  (models, ORM)                      |               Resolution:  duplicate
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by ptone):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => duplicate
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 This is a result of the models being associated with an implicit app_label
 that is derived from the path to the model.

 because the app label namespace is flat, a subsequent attempt to import a
 model named "test" for an app with the label "test" will first check the
 appcache and return an existing model matching that pair of identifiers.
 This is a case of clashing app names/labels and as such is a duplicate of
 #3591

 The real bug here is that no error is raised (in Django 1.4) with the
 following in installed_apps:

 {{{
 'base.a.miscapp',
 'base.b.miscapp',
 ...
 }}}

 this results in two applications with the same label - which will confound
 the model registration process - such a case should raise an error
 pointing out the collision early on.

--
Ticket URL: <https://code.djangoproject.com/ticket/18686#comment:1>
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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Loading...