Thank you Mike Ramirez. [1] makes a difference. I now see the css taking effect.
Mike On Aug 30, 8:55 am, Mike Ramirez <gufym...@gmail.com> wrote: > On Saturday 29 August 2009 04:35:11 pm adelaide_mike wrote: > > > > > As a very newbie I am struggling to understand how to use CSS. I read > > in > > >http://docs.djangoproject.com/en/dev/topics/forms/media/#paths-in-med... > >initions > > > that I need to write: > > class Media: > > css = { > > 'screen': ('pretty.css',), > > 'print': ('newspaper.css',) > > } > > > for example. > > > Where is this code placed, in which file? Is this what I should do? > > Any help or pointers to additional docs for beginners would be > > appreciated. > > > Mike > > That's specifically for forms, that code would go in your forms.py file > normally. The actual css files would be served over your MEDIA_URL. > > Media in general would be served over the static files, in your MEDIA_ROOT > direcotry. You'll need to set up django or your httpd to serve static media > over the MEDIA_URL[1]. Once this is done, you can add in css through the > template using the link html tag. > > There is a template context processor that allows you to use {{ MEDIA_URL }} > in your templates [2] That will make using the link tag easier. The only > problem with this is that if you use styles with the url() setting, you'll > need to change these manually (search and replace works) in your *.css files > or you can write a manage.py command to update the css files for you, when > switching media servers. > > example of MEDIA_ROOT: > > app/media > app/media/css > app/media/js > app/media/images > > example of using media in a template: > <link rel="stylesheet" href="{{ MEDIA_URL }}css/default.css" type="text/css" > media="screen" charset="utf-8" /> > > The files that you have defined for your form media should go in a similar > place and the paths are relative to your MEDIA_URL. > > The default.css for me is a site wide style sheet and I put most of the styles > in there. I don't use the metaclass Media, unless the form field needs a > specific style. > > I hope this helps, > > Mike > > [1]http://docs.djangoproject.com/en/dev/howto/static-files/ > [2]http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c... > > -- > As I was walking down the street one dark and dreary day, > I came upon a billboard and much to my dismay, > The words were torn and tattered, > From the storm the night before, > The wind and rain had done its work and this is how it goes, > > Smoke Coca-Cola cigarettes, chew Wrigleys Spearmint beer, > Ken-L-Ration dog food makes your complexion clear, > Simonize your baby in a Hershey candy bar, > And Texaco's a beauty cream that's used by every star. > > Take your next vacation in a brand new Frigedaire, > Learn to play the piano in your winter underwear, > Doctors say that babies should smoke until they're three, > And people over sixty-five should bathe in Lipton tea. > > signature.asc > < 1KViewDownload --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---