On Thu, Feb 19, 2009 at 7:30 AM, mermer <merme...@googlemail.com> wrote:
> > Since I've upgraded to Django ver 1.00, I'm suddenly getting the > following error with my ImageFields. > > The tag is {{ model.image.url}} and it throws an error if the image > field in the database is null (even if it is set to null in the model) > > Am I missing something? Here is the error message being generated. > > > TemplateSyntaxError at /offer_detail_ver2/1/ > > Caught an exception while rendering: The 'image' attribute has no file > associated with it. > There was some major file storage refactoring done before 1.0, which I'd guess introduced a requirement that attempting to retrieve the url associated with a file-type object requires a file to be associated with that object. A little experimenting in the shell shows that now where {{ m.file.url }} generates the exception you report in the case where m.file has no file, {% if m.file %}{{ m.file.url }}{% endif %} does not. I didn't work on the file storage refactor so I don't know if this was an intentional difference, and I haven't checked if this was explicitly documented as a backwards-incompatible change, but it seems not-so-surprising that such a method would require a file to be set, and easy enough to adjust to? Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---