Images are uploaded to directory which name is constructed from 2 parts:
MEDIA_ROOT + model's upload_to.
Then image url gets constructed from  MEDIA_URL and upload_to (and image
name itself).
So if your C:\django\site_media\ is accessible with web-server, and say
C:/django/ is DOCUMENT_ROOT of Apache for virtual host django_media.local,
and your model  has 'upload_to="site_media/"', then images are uploaded to
c:\django\site_media\IMG_0394.JPG  and are accessible at web as
http:\\django_media.local\site_media\IMG_0394.JPG.

To access images you should setup separate Apache virtual host, I think.



2007/5/9, gsmith <[EMAIL PROTECTED]>:
>
>
> James,
> I use get_image_url and the src is still 'c:/django/site_media/
> IMG_0394.JPG'.  I think their is a property that I don't have
> correct.  Below is a list of properties that might be wrong
>
> settings.py
>
> MEDIA_ROOT = ''
> MEDIA_URL = ''
>
> ////////////////////
>
> urls.py
>
> (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
> {'document_root': 'c:/django/site_media/', 'show_indexes': True}),
>
> ////////////////////
>
> models.py
>
> class members(models.Model):
>     title = models.CharField(maxlength=100)
>     names = models.CharField(maxlength=100)
>     theslug = models.SlugField(prepopulate_from=["names"])
>     email = models.EmailField()
>     city = models.CharField(maxlength=100)
>     state = models.USStateField()
>     image = models.ImageField(upload_to='c:/django/site_media/')
>
> //////////////
>
> members_detail.py
>
> <img src="{{ thetabinfo.get_image_url }}" width="200" height="150" />
>
>
>
>
> Thanks for any help
>
> On May 8, 10:20 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > On 5/8/07, gsmith <[EMAIL PROTECTED]> wrote:
> >
> > > by using the following html '<img src="{{ thetabinfo.image }}"'.
> > > However, this contains the string 'c:/django/site_media/image.jpg'.
> >
> > Use
> >
> > <img src="{{ thetabinfo.get_image_url }}" />
> >
> > The "get_FIELDNAME_url" method will return the URL of the file
> > relative to MEDIA_ROOT, while just printing out the field value will
> > return the filesystem location of the file. This is covered in the
> > documentation:
> >
> > http://www.djangoproject.com/documentation/db-api/#get-foo-url
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to