Hi,
I think , first of all, you should have tags around the url. .
if you are able to get the image if you direct your browser to
http://192.0.0.1:8000/images/photo.jpg ? if yes, then the above is the
solution .
If not then you should set your image files to be served as setatic files.
This might help . https://docs.djangoproject.com/en/1.2/howto/static-files/
Cheers,
On Mon, Dec 24, 2012 at 12:07 AM, That guy wrote:
> Hi there,
>
> I'm trying to create a photo gallery by storing photos in a gallery
> database and pulling them out when appropriate.
>
> However, I ran into the problem of how to publicly expose the pictures in
> urls. In my template, I return a the url of the photo which turns out to be
> images/photo.jpg. However in my development server, when I put in the url
> 192.0.0.1:8000/images/photo.jpg, I can't view the image. Is there any way
> to make the url/image accessible through the url provided by the object
> without manually tampering with urls.py? If not, why does Django provide
> the .url field? Is this the only a recommended url field then?
>
> My View:
>
> def gallery(request):
> base_gallery = gall.objects.get(name="base")
> base_list = base_gallery.photos.all()
> return render_to_response('gallery.html',
> {'list_of_images':base_list},
> context_instance = RequestContext(request),
> )
>
> Template:
>
> {% extends "index.html" %}{% block body_content %}
> {% for photo in list_of_images %}
> {{ photo.image.url }}{% endfor %}{% endblock %}
>
> Model:
>
> from django.db import models
> class photo(models.Model):
> name = models.CharField(max_length=50,blank=True,null=True)
> source_descr = models.CharField(max_length=100,blank=True,null=True)
> image = models.ImageField(upload_to='images')
>
> class gallery(models.Model):
> name = models.CharField(max_length=50)
> photos = models.ManyToManyField(photo)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/crmJYuBCBfgJ.
> 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.
>
--
With Regards,
Ankush Chadda
--
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.