views:

29

answers:

1

Hi,

I'm trying to move from django 1.0.2 to 1.1 and I am getting the

following error in one of my templates:

Request Method: GET

Request URL: http://localhost:8000/conserv/media_assets/vod/

Exception Type: TemplateSyntaxError

Exception Value: Caught an exception while rendering: 'NoneType'

object has no attribute 'label'

Exception Location: /opt/local/Library/Frameworks/Python.framework/

Versions/2.6/lib/python2.6/site-packages/django/template/debug.py in

render_node, line 81

Python Executable: /opt/local/Library/Frameworks/Python.framework/

Versions/2.6/Resources/Python.app/Contents/MacOS/Python

Python Version: 2.6.2

The error is on the line with the "for" tag.

My template:

                    {% for field in upload_image_form %} 

                            <tr> 

                                    <td class="label"> 

                                            {{field.name}} 

                                    </td> 

                                    <td> 

                                            {{field}} 

                                    </td> 

                            </tr> 

                    {% endfor %} 

My form:

class UploadImageForm(ModelForm):

class Meta: 

    model = ImageUpload 

    fields = ('thumb') 

My model:

class ImageUpload(models.Model):

thumb = models.FileField(upload_to='thumbs', blank=True, 

null=True)

Does anyone know how can I solve it?

Thanks,

Arshavski Alexander.

A: 

there's an error in your form class. The fields should be an iterable, but a tuple with one element should be written ('thumb',) instead of ('thumb'). Change your form class to :

class UploadImageForm(ModelForm):
  class Meta: 
    model = ImageUpload 
    fields = ('thumb',)

It should do the trick.

Clément