I am having the same problem placing an image in a template file. I
think you may be farther along than I am, if you understand the
'object.get_mug_shot_url' portion of the instructions. My impression
of the Image_File instructions was that they were intended to allow
users to send images >to< the web server.
I am working in WinXP at the moment. I have currently got my.gif in
C:\temp.
I do not see any difference whether my settings.py file contains
MEDIA_ROOT = '/temp/' or MEDIA_ROOT = '', and the same goes for
MEDIA_URL. The Django development web server is now sending this
message when I hit a page descended from this template:
"GET /descendant_page HTTP/1.1" 200 2294
"GET /temp/my.gif HTTP/1.1" 404 2310
When I use my browser to view my page source, I see "img src =
'/temp/my.gif' (an improvement over "img src = [Didn't have permission
to include file]". Now, I guess that the server simply can't find the
file in the directory I thought I told it to look in.
At one point, I tried using {% ssi /temp/my.gif %}, along with the
ALLOWED_INCLUDE_ROOT = '/temp'
directive in settings.py - that resulted in the of bytes from my.gif
embedded in the page source. I was glad to see the server >did< find
the file, but I wish it had done something more useful with the
contents.
On Jan 24, 8:35 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi group,
>
> I'm just getting started with Django and I've run into a snag with
> images: I've set up the image portion of my site following these
> directions from the Django FAQ:
>
> 1) "In your settings file, define MEDIA_ROOT as the full path to a
> directory where you'd like Django to store uploaded files."
> ** mine is set as the absolute path on my machine
>
> 2) "Define MEDIA_URL as the base public URL of that directory. Make
> sure that this directory is writable by the Web server's user account.
> "
> ** have tried this as both the absolute path and the http path, neither
> works
>
> 3) "Add the FileField or ImageField to your model, making sure to
> define the upload_to option to tell Django to which subdirectory of
> MEDIA_ROOT it should upload files."
> ** used "specimen_image=models.ImageField(upload_to='public/')" in
> models.py
>
> 4) "you can get the absolute URL to your image in a template with {{
> object.get_mug_shot_url }}."
> ** in my template, I refer to src="{{specimen.get_specimen_image_url}}>
>
> When I access the template's associated script through a browser, only
> the alt text is displayed (no image). I can access the image directly
> by entering the absolute path into my browser, but must be missing
> something somewhere along the way in Django. Any ideas?
>
> Thanks! Go Django!
> Heather Y.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---