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 <wayne.tuxro...@gmail.com> wrote: > On Wed, Dec 8, 2010 at 10:49 AM, JeffH <holtzma...@gmail.com> 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 %}<h2>{{ fieldset.name }}</h2>{% endif %} > > 3 {% if fieldset.description %}<div > > class="description">{{ fieldset.description|safe }}</div>{% endif %} > > 4 {% for line in fieldset %} > > 5 <div class="form-row{% if line.errors %} errors{% endif %} {% for > > field in line %}{{ field.field.name }} {% endfor %} "> > > 6 {{ line.errors }} > > 7 {% for field in line %} > > 8 <div{% if not line.fields|length_is:"1" %} class="field-box"{% > > 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.