I am going thru the sample blog application introduced in the book "Python Web Development with Django (covers Django 1.0)".
Before getting too deep into the book, I decided I wanted to first ensure that the application will render in apache since I want to include an image at the bottom of the blog posts (I have been hacking spaghetti code in php for a couple of years now, but now, am intent on coding neatly with python). The blog application works partially in that apache renders the text contents, but not the image. Note the access.log contents in the end ( "GET /media/img/ people_rose.jpg HTTP/1.1" 404 2001) I have read so much good stuff about Django that I want to dive into it full speed ahead, but now I am stuck in serving a simple image. Help? -------------- httpd.conf: ======= . . . </Directory> ################# I will put this later in a separe conf file ########### # This did not work ==>>> AliasMatch ^/([^/]+)/media/(.*) "c:/my_wsgi/ media" # # trying AliasMatch below...still does not work :>( # AliasMatch ^media/(.*) "c:/my_wsgi/media/" <Directory "c:/my_wsgi/media"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> WSGIScriptAliasMatch ^/([^/]+) "c:/my_wsgi/apache/django.wsgi" <Directory "c:/my_wsgi/apache"> Order deny,allow Allow from all </Directory> #################################### # # DirectoryIndex: sets the file that Apache will serve if a directory # is requested. . . . ---------------- django.wsgi: ======== import os, sys #Calculate the path based on the location of the WSGI script. apache_configuration= os.path.dirname(__file__) project = os.path.dirname(apache_configuration) workspace = os.path.dirname(project) sys.path.append(workspace) sys.path.append('c:\\my_wsgi') os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() ---------------- settings.py: ======== . . . # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # trailing slash. # Examples: "http://foo.com/media/", "/media/". ADMIN_MEDIA_PREFIX = '/media/' . . . -------------------------------------------------------------------- base.html (lives in c:\my_wsgi\blog\templates): ================================== . . . <p> {%block content %} {%endblock%} </p> <p><img src="../../media/img/people_rose.jpg" width="564" height="848"> </p> . . . ----------------- access.log: ========= 127.0.0.1 - - [15/Feb/2009:15:05:41 -0800] "GET /blog/v_blog/ HTTP/ 1.1" 200 565 127.0.0.1 - - [15/Feb/2009:15:05:43 -0800] "GET /media/img/ people_rose.jpg HTTP/1.1" 404 2001 127.0.0.1 - - [15/Feb/2009:15:05:44 -0800] "GET /favicon.ico HTTP/1.1" 404 1944 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---