Re: can't add via admin, get django template error

2010-12-09 Thread JeffH
I had defined a custom admin class for that model. I commented it out
and went with the default admin class, and got the same error trying
to create a new record. So didn't think it was the admin.

Then I looked at the date fields on that model. Turned out that
specifying a default date as a string was the problem:
  publish_date = models.DateTimeField(default='2039-12-31') # don't!

Even though it works with a standard ModelForm form, ie gets displayed
in the UI properly, is accepted as a valid date by the Form
validation, and gets inserted into the db properly.

I think that the admin should accept such a (properly formed) date
string. Or else the model shouldn't validate.

On Dec 8, 2:20 pm, Wayne Smith  wrote:
> On Wed, Dec 8, 2010 at 10:49 AM, JeffH  wrote:
> > So I'm working along, everything's humming fine. Then I try to add a
> > record via the admin, and get the following:
>
> > TemplateSyntaxError at /admin/expert/expertresponse/add/
> > Caught AttributeError while rendering: 'unicode' object has no
> > attribute 'date'
>
> > [snip]
>
> > Template error
>
> > In template c:\python26\lib\site-packages\django\contrib\admin
> > \templates\admin\includes\fieldset.html, error at line 12
> > Caught AttributeError while rendering: 'unicode' object has no
> > attribute 'date'
> > 2       {% if fieldset.name %}{{ fieldset.name }}{% endif %}
> > 3       {% if fieldset.description %} > class="description">{{ fieldset.description|safe }}{% endif %}
> > 4       {% for line in fieldset %}
> > 5       
> > 6       {{ line.errors }}
> > 7       {% for field in line %}
> > 8        > endif %}>
> > 9       {% if field.is_checkbox %}
> > 10      {{ field.field }}{{ field.label_tag }}
> > 11      {% else %}
> > 12      {{ field.label_tag }}{{ field.field }}
>
> > I can add records via a ModelForm without problem, it just doesn't
> > work in the admin.
>
> > As you probably surmised from the error, the admin is expecting a field
>
> attribute of type date on your  model object (line?).  Anyway, what is
> getting passed is an Unicode object, which obviously does not have the
> attribute (field) it is looking for.
>
> I would guess that the problem lies somewhere in your admin file
> (admin.py).  What are the contents of it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can't add via admin, get django template error

2010-12-08 Thread Wayne Smith
On Wed, Dec 8, 2010 at 10:49 AM, JeffH  wrote:

> So I'm working along, everything's humming fine. Then I try to add a
> record via the admin, and get the following:
>
> TemplateSyntaxError at /admin/expert/expertresponse/add/
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
>
> [snip]
>
> Template error
>
> In template c:\python26\lib\site-packages\django\contrib\admin
> \templates\admin\includes\fieldset.html, error at line 12
> Caught AttributeError while rendering: 'unicode' object has no
> attribute 'date'
> 2   {% if fieldset.name %}{{ fieldset.name }}{% endif %}
> 3   {% if fieldset.description %} class="description">{{ fieldset.description|safe }}{% endif %}
> 4   {% for line in fieldset %}
> 5   
> 6   {{ line.errors }}
> 7   {% for field in line %}
> 8endif %}>
> 9   {% if field.is_checkbox %}
> 10  {{ field.field }}{{ field.label_tag }}
> 11  {% else %}
> 12  {{ field.label_tag }}{{ field.field }}
>
> I can add records via a ModelForm without problem, it just doesn't
> work in the admin.
>
> As you probably surmised from the error, the admin is expecting a field
attribute of type date on your  model object (line?).  Anyway, what is
getting passed is an Unicode object, which obviously does not have the
attribute (field) it is looking for.

I would guess that the problem lies somewhere in your admin file
(admin.py).  What are the contents of it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



can't add via admin, get django template error

2010-12-08 Thread JeffH
So I'm working along, everything's humming fine. Then I try to add a
record via the admin, and get the following:

TemplateSyntaxError at /admin/expert/expertresponse/add/
Caught AttributeError while rendering: 'unicode' object has no
attribute 'date'

[snip]

Template error

In template c:\python26\lib\site-packages\django\contrib\admin
\templates\admin\includes\fieldset.html, error at line 12
Caught AttributeError while rendering: 'unicode' object has no
attribute 'date'
2   {% if fieldset.name %}{{ fieldset.name }}{% endif %}
3   {% if fieldset.description %}{{ fieldset.description|safe }}{% endif %}
4   {% for line in fieldset %}
5   
6   {{ line.errors }}
7   {% for field in line %}
8   
9   {% if field.is_checkbox %}
10  {{ field.field }}{{ field.label_tag }}
11  {% else %}
12  {{ field.label_tag }}{{ field.field }}

I can add records via a ModelForm without problem, it just doesn't
work in the admin.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.