> I started learning Django at PyCon in Chicago and have worked > most of the way through the "Django Book" and Sams "Teach > Yourself Django", as well as "Head First HTML with CSS and > XHTML". It's been quite a lot for this old dog, but I'd like > to take a crack a writing my own web site using Django.
welcome aboard! > I have two problems, and I think they are related. They are indeed > to documentation on how to get the web server to "serve" the > images. I hate to put it this bluntly, but I don't know what > that means To "serve" simply means that the web-server (usually Apache or lighttpd) listens for requests for files and responds by "serving" them. An example might be C: GET /blog/2008/3/14/my-pi-day-post HTTP/1.1 C: Host: www.example.com S: HTTP/1.1 200 OK S: Date: Mon, 23 May 2005 22:38:34 GMT S: Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) S: Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT S: Etag: "3f80f-1b6-3e1cb03b" S: Accept-Ranges: bytes S: Content-Length: 438 S: Connection: close S: Content-Type: text/html; charset=UTF-8 S: S: <html><body>My first blog page</body></html> (C = client/webbrowser, S = server). It may be helpful to learn some rudimentary HTTP (the protocol over which all of this is being served). http://en.wikipedia.org/wiki/HTTP Or at least install the "Live HTTP Headers" FireFox extension that allows you to watch/record the HTTP transactions. But the basic gist is that your browser requests a page; the server "serves" this page (dynamically, created by via Django). Your browser then sees references to other external files (images, CSS, JavaScript, etc) and makes requests for each of these. The server receives each request and returns ("serves") the requested content--an image, a CSS file, a JavaScript file, or even additional dynamic content from another Django source. > I would like to know how to "do" images locally, then what I > need to do when I host my site. > > The other problem is getting css to work with my site. Both images and CSS files (as well as JavaScript source files, when you get there) are considered "static media". Django's development server can serve these static media files. I like to use the following in my urls.py file: if 'runserver' in argv: urlpatterns += patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT} ), ) This allows me to serve media from the development server (which get put in the directory specified by MEDIA_ROOT), but it doesn't alter my urlpatterns in production where the actual web-server handles serving media. To move to production, you'll want to configure your server (likely Apache or lighttpd) to serve these static files. The server is very good at serving static (non-dynamic content), so it's best to let it handle these files. Django *can* handle them, but it's not designed to do as much (it's designed to serve dynamic content). There's a good writeup at http://www.djangoproject.com/documentation/static_files/ regarding how to configure your web-server (Apache or lighttpd) for serving these static files outside of Django. Hopefully this gives you some hints, pointers in the right direction, terminology to search the web, and tips in general to get things working. As always, the list is a pretty friendly place, and will try and help guide you. -tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---