Thank you all for your input. It turns out my settings file was improperly
configured. I needed to change MEDIA_ROOT and MEDIA_URL

On Tue, Apr 7, 2015 at 12:30 PM, Luis Zárate <[email protected]> wrote:

> Hi,
>
> Django provide for development MEDIA_URL and MEDIA_ROOT for uploaded file,
> for production used static deploy strategy, see the documentation about
> static files.
>
> Model file field has an url attribute that return a media url, you use in
> template like {{obj.file.url}}
>
>
> El martes, 7 de abril de 2015, Stephanie Socias <[email protected]>
> escribió:
> > Do I need to update/add something to my urls.py?
> >
> > On Tuesday, April 7, 2015 at 9:51:56 AM UTC-4, Stephanie Socias wrote:
> >>
> >> 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 <[email protected]>
> 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
> [email protected].
> >>> To post to this group, send email to [email protected].
> >>> 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
> .
> >>> 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 [email protected].
> > To post to this group, send email to [email protected].
> > 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/b015d26d-c95a-4435-bd93-107244d5a798%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
>
>  --
> 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
> [email protected].
> To post to this group, send email to [email protected].
> 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/CAG%2B5VyNHO5H1m_dtE3WVrPE4FgSZ%3D%3Dckj-YFZWdoEWVxU4AKgA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyNHO5H1m_dtE3WVrPE4FgSZ%3D%3Dckj-YFZWdoEWVxU4AKgA%40mail.gmail.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 [email protected].
To post to this group, send email to [email protected].
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%3DD6Wod%3DGaReJsjbieHODQtJxy%3DG_kX7uztxWYp3FoVRT7-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to