[Django] #24809: Won't load templates from apps directory without a model

5 views
Skip to first unread message

Django

unread,
May 16, 2015, 9:03:22 PM5/16/15
to django-...@googlegroups.com
#24809: Won't load templates from apps directory without a model
---------------------------------+------------------------
Reporter: camiloforero | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8
Severity: Normal | Keywords: app loader
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------
When creating a new app, the templates loader won't look at the
<appname>/templates directory if there are no models of it migrated to the
database, throwing a TemplateDoesNotExist exception and showing in the
postmortem that it only looked for them in the 'auth' and 'admin'
application template directories. The new app had already been added to
the 'INSTALLED_APPS' section of the settings.py file. Doing a
makemigrations and a migrate did nothing

This was fixed after I created a dummy class in <appname>/models.py, and
did a makemigrations->migrate. So my guess is that the template loader
relies somehow in the database, and if there is no reference to an app on
it then it won't look at it's templates directories despite it being on
the INSTALLED_APPS tuple. So I don't know if that's intended behaviour or
not, but here I call it to your attention.

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

Django

unread,
May 17, 2015, 3:31:54 AM5/17/15
to django-...@googlegroups.com
#24809: Won't load templates from apps directory without a model
---------------------------------+--------------------------------------

Reporter: camiloforero | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.8
Severity: Normal | Resolution:

Keywords: app loader | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by bmispelon):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Hi,

I just tried to reproduce your issue using the following app structure:
{{{
bug24809/
├── __init__.py
└── templates
└── foo.html

}}}

After I added the app to `settings.INSTALLED_APPS`, I tried
`django.template.loader.get_template('foo.html')` and it did return a
template object (no `TemplateDoesNotExist` exception).

Do you have more information on how to reproduce your issue?
Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/24809#comment:1>

Django

unread,
May 17, 2015, 5:00:26 AM5/17/15
to django-...@googlegroups.com
#24809: Won't load templates from apps directory without a model
---------------------------------+--------------------------------------
Reporter: camiloforero | Owner: nobody
Type: Bug | Status: closed

Component: Template system | Version: 1.8
Severity: Normal | Resolution: needsinfo

Keywords: app loader | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by aaugustin):

* status: new => closed
* resolution: => needsinfo


Comment:

Given the amount of work that was put in Django 1.7 to make sure models.py
is optional, I'm pretty sure this isn't a behavior you'll see with vanilla
Django. The template layer is also decoupled from the model layer, so
there's no reason they would interact like this. Something else must be
going on in your project.

--
Ticket URL: <https://code.djangoproject.com/ticket/24809#comment:2>

Django

unread,
May 17, 2015, 1:52:13 PM5/17/15
to django-...@googlegroups.com
#24809: Won't load templates from apps directory without a model
---------------------------------+--------------------------------------
Reporter: camiloforero | Owner: nobody
Type: Bug | Status: closed

Component: Template system | Version: 1.8
Severity: Normal | Resolution: needsinfo

Keywords: app loader | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by camiloforero):

I just tried to reproduce the issue but this time it worked as normal,
with no models. The error must have been somewhere else. Thank you

--
Ticket URL: <https://code.djangoproject.com/ticket/24809#comment:3>

Django

unread,
May 17, 2015, 4:00:51 PM5/17/15
to django-...@googlegroups.com
#24809: Won't load templates from apps directory without a model
---------------------------------+--------------------------------------
Reporter: camiloforero | Owner: nobody
Type: Bug | Status: closed

Component: Template system | Version: 1.8
Severity: Normal | Resolution: invalid

Keywords: app loader | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by timgraham):

* resolution: needsinfo => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/24809#comment:4>

Reply all
Reply to author
Forward
0 new messages