#32938: App name changes and is confusing to use across a project
-----------------------------------------+------------------------
               Reporter:  Michael        |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  3.2
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 I hope this is just a case of "you doing it wrong". This issue has been a
 thorn in my side for so long, and is an issue of constant confusion for
 me. So like many larger projects, my applications doesnt have all the
 django apps in the root folder. I created a framework as follows:

 **project_root**
     - **core** - contains essentials apps for the framework
     - **applib** - contains apps that a certain deployment may or may not
 use
     - **dist** - contains apps that are only used for a certain
 distribution

 Now say there is app **foo** within **core**, then from experimentation
 (as in things don't work otherwise) one must set:
 {{{
 # Filename: project_root/core/foo/apps.py
 from django.apps import AppConfig

 class FooConfig(AppConfig):
     name = 'core.foo'  # I hope here I am doing it wrong, and this is the
 source of trouble
 }}}

 Okay great so the app name must include the dotted path from the project
 root, no problem. So now all the **reverse(...)** and **{% url '...' %}**
 use this dotted path app name.

 Then say one has an issue of circular imports with models, so one must
 lazy import the model name. However it does not use the app name, it uses
 some other combination, after trying various ways turns out it must be in
 like this:

 {{{
 # Filename: applib/bar/models.py

 class BarModel(models.Model):
     foo = models.ForeignKey('foo.FooModel', on_delete=models.PROTECT,
 null=True, blank=True)
 }}}
 Notice how now the appname is '**foo**', whereas most of the time it is
 '**core.foo**'.
 Additionally with migrations it uses this shorter app name. If one looks
 in the django_migration table and migration files, one sees  '**foo**'
 instead of '**core.foo**' (which is what it was explicitly set to).

 Is this not a bit confusing?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32938>
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/053.fda576e084083bcc4e648dd85fe2d095%40djangoproject.com.

Reply via email to