Value Error after update to latest Django

22 views
Skip to first unread message

Steve Potter

unread,
Jun 13, 2008, 8:47:35 PM6/13/08
to Django users
I just updated the the latest version of Django and I started getting
the following error in the admin interface:

Caught an exception while rendering: invalid literal for int() with
base 10: 'None'

It seems to be the result of a model I have with a DateTimeField with
both null and blank set to True, and a date_hierarchy set on the same
field.

Here is an example model that can re-produce the error:

class Post(models.Model):
title = models.CharField(max_length=100)
publish_date = models.DateTimeField(null=True, blank=True)

def __unicode__(self):
return unicode(self.title)

class Admin:
date_hierarchy = 'publish_date'

If I revert to a version of Django from before the qs-rf merge the
error goes away.

I have looked through the Backwards Incompatible changes and can't
seem to find anything that would explain it.

Is there some sort of work-around, or is this a bug?

Thanks,

Steven

Steve Potter

unread,
Jun 14, 2008, 4:50:48 PM6/14/08
to Django users
I realized that I left a few things out when describing the problem.
The error occurs when trying to access the change_list portion of the
admin interface after a record has been inserted with a null date.

Here is more details on the error produced:


Template error

In template c:\python25\lib\site-packages\django\contrib\admin
\templates\admin\change_list.html, error at line 16
Caught an exception while rendering: invalid literal for int() with
base 10: 'None'
6 {% block coltype %}flex{% endblock %}
7 {% block content %}
8 <div id="content-main">
9 {% block object-tools %}
10 {% if has_add_permission %}
11 <ul class="object-tools"><li><a href="add/{% if is_popup %}?
_popup=1{% endif %}" class="addlink">{% blocktrans with
cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans
%}</a></li></ul>
12 {% endif %}
13 {% endblock %}
14 <div class="module{% if cl.has_filters %} filtered{% endif %}"
id="changelist">
15 {% block search %}{% search_form cl %}{% endblock %}
16 {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
17 {% block filters %}{% filters cl %}{% endblock %}
18 {% block result_list %}{% result_list cl %}{% endblock %}
19 {% block pagination %}{% pagination cl %}{% endblock %}
20 </div>
21 </div>
22 {% endblock %}
23

So the error is a result of the null dated being processed by the
date_hierarchy tag.

Any ideas?

Thanks,

Steve

Karen Tracey

unread,
Jun 14, 2008, 5:02:05 PM6/14/08
to django...@googlegroups.com

Searching here:

http://code.djangoproject.com/search

for date_heirarchy brings up an open ticket:

http://code.djangoproject.com/ticket/7199

So looks like someone else has hit this and reported it already.  The report includes some analysis of where the error is occurring but no patch, and apparently no on else has had a chance to look at this yet (since the ticket is still in Unreviewed state).  If you want to help the process along you could try your hand at coming up with a patch to fix the error.

Karen

Steve Potter

unread,
Jun 14, 2008, 7:04:41 PM6/14/08
to Django users

>
> Searching here:
>
> http://code.djangoproject.com/search
>
> for date_heirarchy brings up an open ticket:
>
> http://code.djangoproject.com/ticket/7199
>
> So looks like someone else has hit this and reported it already. The report
> includes some analysis of where the error is occurring but no patch, and
> apparently no on else has had a chance to look at this yet (since the ticket
> is still in Unreviewed state). If you want to help the process along you
> could try your hand at coming up with a patch to fix the error.
>
> Karen

Thanks for pointing out the bug report. The original poster of the
bug report seems to have narrowed down the problem. I will see what I
can do to fix it.

Thanks,

Steve
Reply all
Reply to author
Forward
0 new messages