Hi, I have a model like this: class Bookmark(models.Model): title = models.CharField(max_length=200) user = models.ForeignKey(User) link = models.ForeignKey(Link) desc = models.CharField(max_length=500) photo = models.ImageField(upload_to="photos/") thumbnail = models.ImageField(upload_to="thumbnails/") def __str__(self): return '%s, %s' % (self.user.username, self.link.url)
I am able to upload a file through a form and save it to a directory using this code in views.py (I am not using ModelForms): def handle_uploaded_file(f): destination = open('/home/dmc/projects/django_bookmarks/site_media/photos/file.jpg', 'wb+') for chunk in f.chunks(): destination.write(chunk) destination.close() When I try to access the image file using following in a template: <img src='{{ bookmark.photo.url }}' alt='{{ bookmark.title }}' /> I get an error saying "The 'photo' attribute has no file associated with it." Looking at the database, I see a photo and thumbnail columns, but there is no data. Do I need to write code to store a link to images in the photo and thumbnail columns? Thank you, --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---