[Django] #16502: CreateView useless error message when template_name is not specified

57 views
Skip to first unread message

Django

unread,
Jul 23, 2011, 9:27:04 AM7/23/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
---------------------------------------+-------------------------------
Reporter: silverghost3@… | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Generic views
Version: 1.3 | Severity: Normal
Keywords: CreateView "generic view" | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+-------------------------------
According to documentation CreateView should use
`%app_name%/%model_name%_form.html` template by default. But if
template_name is not specified it returns uninformative error:

{{{
Traceback (most recent call last):

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/contrib/staticfiles/handlers.py", line 68, in
__call__
return self.application(environ, start_response)

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/core/handlers/wsgi.py", line 273, in __call__
response = self.get_response(request)

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/core/handlers/base.py", line 203, in
handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/views/debug.py", line 59, in technical_500_response
html = reporter.get_traceback_html()

File "/home/kirill/workplace/projects/createview_test/lib/python2.7
/site-packages/django/views/debug.py", line 89, in get_traceback_html
for loader in template_source_loaders:

TypeError: 'NoneType' object is not iterable
}}}

There is not anything except traceback on white background.

It will be cool if there will be default template for CreateView. If it
is not a bug then note that `template_name` is required would be useful.

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

Django

unread,
Jul 23, 2011, 10:12:05 AM7/23/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
silverghost3@… | Status: new
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: 1.3 | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: | Has patch: 0
Unreviewed | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

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


Comment:

Actually, this is a crash of the debug view itself.

When Django encounters a `TemplateDoesNotExist` exception, the debug view
attempts to gather information about available template loaders and
templates. It relies on the fact that
`django.template.loaders.template_source_loaders` is already populated (by
`django.template.loaders.find_template`). But in your case, it isn't. So a
new exception is raised, it overrides the initial exception, and —
unfortunately — it makes it difficult to understand what really happens
here.

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

Django

unread,
Jul 23, 2011, 12:08:39 PM7/23/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: 1.3 | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by Silver_Ghost):

* status: new => assigned
* owner: nobody => Silver_Ghost
* stage: Unreviewed => Accepted


Comment:

''aaugustin'', through information from your comment I was able to find
possible place in code where additional check could be perfomed. It is
`django.template.loader.select_template` function.

It expects list of template names and select first loadable. If there are
some template names in list and no one from them couldn't be loaded then
raising `TemplateDoesNotExist` exception is the right decision since. But
if there isn't any template names in the list then
>>Template<<DoesNotExist is wrong exception, I think.

So maybe checks if list is empty and raise exception with message like "I
can't load any template for you because you didn't gave me any possible
variants"?

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

Django

unread,
Jul 23, 2011, 12:11:12 PM7/23/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: 1.3 | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by Silver_Ghost):

* has_patch: 0 => 1


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

Django

unread,
Jul 23, 2011, 12:15:26 PM7/23/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by Silver_Ghost):

* version: 1.3 => SVN


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

Django

unread,
Aug 14, 2011, 4:40:01 PM8/14/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by zuko):

* cc: anton@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:5>

Django

unread,
Aug 16, 2011, 1:19:08 AM8/16/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by bhuztez):

* cc: bhuztez (added)


Comment:

function-based generic view,
`django.views.generic.create_update.create_object`, use default template
if no template_name is given. When you switch to class-based view,
`CreateView` will not work as you has expected, since
`django.views.generic.edit.CreateView` has no default template. This must
be a bug, please give `CreateView` a default template in 1.3.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:6>

Django

unread,
Sep 5, 2011, 4:50:28 PM9/5/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 1
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by tinodb):

* cc: tinodb (added)
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:7>

Django

unread,
Sep 14, 2011, 1:22:09 PM9/14/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by Silver_Ghost):

* needs_tests: 1 => 0


Comment:

I've merged my and ''bhustez'' 's patches and added regression tests for
both.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:8>

Django

unread,
Sep 15, 2011, 1:01:04 AM9/15/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by ptone):

* cc: preston@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:9>

Django

unread,
Sep 15, 2011, 1:25:18 AM9/15/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 1 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by ptone):

* needs_better_patch: 0 => 1


Comment:

There are too many issues being addressed here in one patch.

The ticket is valid and seeks the addition of a default template to
CreateView

Patches addressing how the template loader works, or a missing get_model
method on SingleObjectMixin should have their own tickets opened and
patches submitted.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:10>

Django

unread,
Sep 17, 2011, 5:45:15 AM9/17/11
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: | Owner: Silver_Ghost
silverghost3@… | Status: assigned
Type: Bug | Component: Generic views
Milestone: | Severity: Normal
Version: SVN | Keywords: CreateView "generic
Resolution: | view"
Triage Stage: Accepted | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by Silver_Ghost):

* needs_better_patch: 1 => 0
* easy: 0 => 1


Comment:

According to [https://groups.google.com/d/topic/django-
developers/jCsXf3eEqb4/discussion this discussion] patch for
`select_template` was separated to ticket:16866. Patch with `get_model`
was left here since there are multiple ways to define which model should
be used (the self.model, self.queryset or self.form_class attributes) and
it justifies having a utility function for it.

Tests provided.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:11>

Django

unread,
Feb 3, 2012, 2:01:08 PM2/3/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | Silver_Ghost
Component: Generic views | Status: assigned
Severity: Normal | Version: SVN
Keywords: CreateView "generic | Resolution:
view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by charettes):

Just hit this issue, any chances this get attention for 1.4?

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:12>

Django

unread,
Feb 12, 2012, 11:22:37 PM2/12/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | Silver_Ghost
Component: Generic views | Status: assigned
Severity: Normal | Version: SVN
Keywords: CreateView "generic | Resolution:
view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by bhuztez):

update Silver_Ghost's patch for revision 17517

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:13>

Django

unread,
May 9, 2012, 4:51:32 PM5/9/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: aaugustin
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* status: assigned => new
* owner: Silver_Ghost => aaugustin


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:14>

Django

unread,
Jun 28, 2012, 4:09:42 AM6/28/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: aaugustin
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by bhuztez):

my pull request: https://github.com/django/django/pull/177

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:15>

Django

unread,
Aug 18, 2012, 12:38:44 PM8/18/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: aaugustin
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by andrewgodwin):

* needs_better_patch: 0 => 1


Comment:

I don't like the way this patch/pull request works with ModelForms - it
magically extracts a model from a ModelForm, which already needs
discussion as it's new behaviour, but even worse it then passes that model
out and then makes a brand new ModelForm out of it - that shouldn't
happen.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:16>

Django

unread,
Aug 18, 2012, 10:42:30 PM8/18/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: aaugustin
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by bhuztez):

> I don't like the way this patch/pull request works with ModelForms - it
magically extracts a model from a ModelForm, which already needs
discussion as it's new behaviour

Yes, but it is not a new behaviour, the function-based generic view
counterpart did the same magic. I did not know whether or not the design
decision had been changed to not providing a default `template_name`. To
provide a default `template_name`, I don't think there is a much less
magical way , given current ModelForm API.

https://github.com/django/django/blob/stable/1.4.x/django/views/generic/create_update.py#L29


> but even worse it then passes that model out and then makes a brand new
ModelForm out of it - that shouldn't happen.

No, it does not. If `form_class` already exists, it will NOT make a new
`ModelForm` from `model` extracted from that, it will just return
`form_class` you defined. The function-based generic view counterpart did
the same.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:17>

Django

unread,
Sep 8, 2012, 2:03:01 PM9/8/12
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: nobody
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* owner: aaugustin => nobody


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:18>

Django

unread,
May 18, 2013, 11:43:31 AM5/18/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by krak3n):

* owner: nobody => krak3n


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:19>

Django

unread,
May 19, 2013, 5:21:18 AM5/19/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: closed

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | worksforme

view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by krak3n):

* status: assigned => closed


* needs_better_patch: 1 => 0

* resolution: => worksforme


Comment:

I was unable to duplicate this in 1.5.1.

I created a basic model as below:

{{{
#!div style="font-size: 80%"
#models.py
}}}
{{{#!python
from django.db import models

class Author(models.Model):
name = models.CharField(max_length=100)
}}}

A basic view:
{{{
#!div style="font-size: 80%"
#views.py
}}}
{{{#!python
from django.views.generic import CreateView
from .models import Author

class CreateAuthor(CreateView):
model = Author
}}}

The traceback I got back was:

{{{
TemplateDoesNotExist at /
test_16502/author_form.html
Request Method: GET
Request URL: http://10.10.10.10:9000/
Django Version: 1.5.1
Exception Type: TemplateDoesNotExist
Exception Value:
test_16502/author_form.html
Exception Location:
/home/vagrant/django/django/django/template/loader.py in select_template,
line 194
Python Executable: /home/vagrant/.virtualenvs/django/bin/python
Python Version: 2.7.3
}}}

I think this is the correct exception that should be raised and the
exception is present in the regular debug view.

Perhaps this was an issue with earlier versions of Django and it's been
resolved in another ticket, though I can't hunt this down. Perhaps related
to ticket:16866?

Perhaps if this is still a bug provide more information on how to
reproduce it.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:20>

Django

unread,
May 19, 2013, 10:06:31 AM5/19/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: new

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by bhuztez):

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


Comment:

set `form_class` rather than `model`

https://code.djangoproject.com/attachment/ticket/16502/get_model_with_tests.3.diff#L168

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:21>

Django

unread,
Jul 15, 2013, 1:45:59 PM7/15/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:22>

Django

unread,
Sep 2, 2013, 2:29:46 AM9/2/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by magicharshit):

Replying to [comment:22 timo]:

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:23>

Django

unread,
Sep 6, 2013, 5:13:14 PM9/6/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner: krak3n
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: CreateView "generic | Triage Stage: Accepted
view" | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by jambonrose):

This is all a little convoluted. There is no longer one problem at hand,
and a little clarification might be useful.

Bug 1: `get_template_names()` (as defined in
`SingleObjectTemplateResponseMixin`) is returning `None`, which is causing
Django to throw a `TemplateDoesNotExist`. This should instead throw a
`ImproperlyConfigured` error, as it does not have the information to
determine the template file to load. This is more eloquently described in
#18853 (marked as duplicate to this topic)

Bug 2: The `TemplateDoesNotExist` exception is causing the server error
message, as detailed (and solved) in #21058.

Feature Request 1: Creating a CBGV by only overriding the `form_class`
variable. The patch provided creates the ability to do so, but does not
actually solve the bugs detailed.

I spoke to Russel about the possibility of the new feature. Unfortunately,
determining the model based off a form specified in `form_class` is not
desirable, because this assumes the form is a ModelForm, which may not be
the case. As such, this feature (and patch) will therefore not be approved
for Django.

This leaves only Bug 1 to be solved.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:24>

Django

unread,
Sep 6, 2013, 5:35:37 PM9/6/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | ianawilson

Component: Generic views | Status: assigned
Severity: Normal | Version: master
Keywords: CreateView "generic | Resolution:

view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ianawilson):

* cc: ianawilson (added)


* needs_better_patch: 1 => 0

* status: new => assigned

* owner: krak3n => ianawilson


Comment:

Here is a pull request to fix Bug 1, as described by @jambonrose.

https://github.com/django/django/pull/1580

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:25>

Django

unread,
Sep 6, 2013, 6:31:31 PM9/6/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | ianawilson
Component: Generic views | Status: closed
Severity: Normal | Version: master
Keywords: CreateView "generic | Resolution: fixed

view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Russell Keith-Magee <russell@…>):

* status: assigned => closed

* resolution: => fixed


Comment:

In [changeset:"9b2dc12b8332389d1bfb9e83123a088a084a6a47"]:
{{{
#!CommitTicketReference repository=""
revision="9b2dc12b8332389d1bfb9e83123a088a084a6a47"
Merge pull request #1580 from ianawilson/ticket_16502

Fixed #16502 -- Fixed a TemplateDoesNotExist error that should be an
ImproperlyConfigured.

Assistance on the patch from #jambronrose.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:26>

Django

unread,
Sep 6, 2013, 6:40:04 PM9/6/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | ianawilson
Component: Generic views | Status: closed
Severity: Normal | Version: master
Keywords: CreateView "generic | Resolution: fixed
view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Russell Keith-Magee <russell@…>):

In [changeset:"99952bab3008622b05613ed6ec54c3e1c63c0a1d"]:
{{{
#!CommitTicketReference repository=""
revision="99952bab3008622b05613ed6ec54c3e1c63c0a1d"
[1.6.x] Merge pull request #1580 from ianawilson/ticket_16502

Fixed #16502 -- Fixed a TemplateDoesNotExist error that should be an
ImproperlyConfigured.

Assistance on the patch from #jambronrose.

Backport of 9b2dc12b8332389d1bfb9e83123a088a084a6a47 from master.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:27>

Django

unread,
Sep 6, 2013, 11:05:10 PM9/6/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | ianawilson
Component: Generic views | Status: new

Severity: Normal | Version: master
Keywords: CreateView "generic | Resolution:
view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bhuztez):

* status: closed => new

* resolution: fixed =>


Comment:

> determining the model based off a form specified in `form_class` is not
desirable, because this assumes the form is a ModelForm, which may not be
the case.

`CreateView` inherits `ModelFormMixin`. This already assumes form is a
ModelForm.

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:28>

Django

unread,
Sep 18, 2013, 4:15:39 PM9/18/13
to django-...@googlegroups.com
#16502: CreateView useless error message when template_name is not specified
-------------------------------------+-------------------------------------
Reporter: silverghost3@… | Owner:
Type: Bug | ianawilson
Component: Generic views | Status: closed
Severity: Normal | Version: master
Keywords: CreateView "generic | Resolution: fixed

view" | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timo):

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


Comment:

@bhuztez I'm going to re-close this and ask that you please open a new
ticket since we try to have one issue per ticket. I think the feature
request and patch look reasonable, but it's a bit difficult to follow the
conversation. Could you please a new ticket that summarizes the details
and include the most recent patch? I think the existing patch also needs
documentation. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/16502#comment:29>

Reply all
Reply to author
Forward
0 new messages