Thank you very much for responding, Daniel.

I'm sorry I don't quite follow- I've never done this before. I should use
the URL {{ datamine.image.url }} in the template?

On Tue, Apr 7, 2015 at 5:36 AM, Daniel Roseman <dan...@roseman.org.uk>
wrote:

> On Monday, 6 April 2015 22:38:36 UTC+1, Stephanie Socias wrote:
>>
>> I've implemented this same solution (using custom file storage and the
>> "upload_to" parameter) but now cannot get the uploaded files to display
>> from my template. I would normally use {{ STATIC_URL }} but, since I've now
>> specified a custom location, I'm not sure why my path, which I've
>> hard-coded in the template, isn't working...any ideas?
>>
>> fs = FileSystemStorage(location='/data/www/upload')
>> def image_location(instance, filename):
>>     return '/'.join(['thumbnails', str(instance.dataset_id), filename])
>> class DataModel(models.Model):
>>     name = models.CharField()
>>     date = models.DateField(blank=True)
>>     image = models.ImageField(storage=fs, upload_to=image_location, 
>> blank=True)
>>
>> template.html
>>
>> <a href="{% url 'myproj:items' %}">
>>     <img class="media-object img-thumbnail" src="/data/www/upload/{{ 
>> datamine.image }}" alt="Data Image Here" height="130" width="130"></a>
>>
>>
> But /data/www/upload/... is the file path of your upload, not the URL. You
> still need an actual URL that is served by your webserver. Obviously, a
> browser can't access arbitrary file paths on your server.
> --
> DR.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/aHa0WWHGreY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e14088d0-7c4a-4965-b88a-2fd0b26ec3cb%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e14088d0-7c4a-4965-b88a-2fd0b26ec3cb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOw%3DD6XU%2BQmk8ZoqJXoFuAtFzKvZG487_eUZ%3DkkyphQDdVgN3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to