Ok finally got it. David Zhou above, earlier mentioned adding static file directory to css link (ie, <link rel="stylesheet" type="text/css" href="/media/css/styles.css"> ) but when i did that it didn't work. I must have had something wrong somewhere else. Anyway, i made some more changes after reading info here: http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates
So given above directory structure i have this working now with the following: settings.py MEDIA_ROOT = 'c:/dev/proj/app/media/' (i changed from 'c:\dev\proj\app \media\' not sure if it mattered) MEDIA_URL = '/media/' ADMIN_MEDIA_PREFIX = '/adminmedia/' from what i gather, media and admin_media can't be the same directory urls.py (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), base.html template <link rel="stylesheet" type="text/css" href="/media/css/styles.css"> What a effin hassle this has been. Django needs inprovement here. Nothing wrong with building a recommended directory structure and/or publishing better instructions on this. This type of thing is very different for people coming from standard page style development. Dir structure and url routing seem to be built into most MVC systems (at least the ones i looked into before django). On Jan 22, 12:32 pm, john <johnwalla...@gmail.com> wrote: > ah ok. good catch. My MEDIA_ROOT = C:\dev\proj. But my media directory > is actually in my app directory, one directory down. I fixed > MEDIA_ROOT to equal C:\dev\proj\app and still not having any luck. my > use of -\ in directory structure example is just to indicate a folder > in directory tree. Let me clarify: > > C:\dev\proj is project directory > C:\dev\proj\app is application directory. Under this i have > 'adminmedia', 'media' and 'templates' directories. So static files are > here: C:\dev\proj\app\media. > css file is here: C:\dev\proj\app\media\css\styles.css > settings file is here: C:\dev\proj\settings.py > > like i said i now have MEDIA_ROOT set to C:\dev\proj\app, but still > not working. In template i was told to use <link rel="stylesheet" > type="text/css" href="{{MEDIA_URL}}css/styles.css">. > > MEDIA_URL not MEDIA_ROOT > > regardless, do i have to pass context for MEDIA_URL in view so > template knows what it is?? is that the problem? > > Thanks for helping, btw. Much appreciated. > > On Jan 22, 11:57 am, Puneet Madaan <puneetmad...@gmail.com> wrote: > > > well at my side it works well on both *nix and windoof platforms... here is > > what I use on my projects... > > > settings.py > > -------------- > > import platform > > import os > > > PROJECT_DIR = os.path.dirname( os.path.abspath(__file__)) > > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static') > > ----------- > > > urls.py > > ----------------- > > from django.conf.urls.defaults import * > > from django.contrib import admin > > from django.conf import settings > > > urlpatterns = patterns('', > > #urls for your project > > (r'^static/(?P<path>.*)$', 'django.views.static.serve', > > {'document_root': settings.MEDIA_ROOT}), > > ) > > ------------ > > where i use a directory named 'static' residing in same folder, where i have > > my settings.py .... can you please place 'print MEDIA_ROOT' inside your > > settings.py and check the terminal the path is spilts out ? because your '-' > > convention before '-\media' is sort confusing, and its missing before > > manage.py and settings.py ---- is media folder residing really in the same > > directory where settings.py ? > > > c:\dev > > > > -\proj > > > __init__.py > > > manage.py > > > settings.py > > > urls.py > > > -\app > > > -__init__.py > > > -admin.py > > > -models.py > > > -views.py > > > -\adminmedia > > > -\media > > > -\css > > > -styles.css > > > -\images > > > -\templates > > > -base.html > > > -index.html > > > if 'print MEDIA_ROOT' spilts out a path different from your media folder, > > then you know where is the problem .. > > > Greetings, > > Puneet > > > On Thu, Jan 22, 2009 at 5:40 PM, john <johnwalla...@gmail.com> wrote: > > > > Thanks but no change. > > > > On Jan 22, 11:30 am, Puneet Madaan <puneetmad...@gmail.com> wrote: > > > > beside <link rel="stylesheet" type="text/css" > > > href="{MEDIA_URL}css/styles.css"> > > > > you need to correct settings.py to > > > > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__)) > > > > > On Thu, Jan 22, 2009 at 5:26 PM, john <johnwalla...@gmail.com> wrote: > > > > > > Thanks but no change. > > > > > > On Jan 22, 11:02 am, Dj Gilcrease <digitalx...@gmail.com> wrote: > > > > > > change > > > > > > <link rel="stylesheet" type="text/css" href="/css/styles.css"> > > > > > > to > > > > > > <link rel="stylesheet" type="text/css" > > > href="{MEDIA_URL}css/styles.css"> > > > > > > > Dj Gilcrease > > > > > > OpenRPG Developer > > > > > > ~~http://www.openrpg.com > > > > > > > On Thu, Jan 22, 2009 at 8:53 AM, john <johnwalla...@gmail.com> > > > wrote: > > > > > > > > No matter what i do i can't get my css to load. 100% Frustrated > > > with > > > > > > > Django. My index page loads when i requesthttp:// > > > 127.0.0.1:8000/but > > > > > > > it is not styled. Django dev server returns 404 in console for > > > > > > > "GET > > > / > > > > > > > css/styles.css HTTP/1.1" > > > > > > > > In my base template i have: > > > > > > > <link rel="stylesheet" type="text/css" href="/css/styles.css"> > > > > > > > > In my urls.py I have: > > > > > > > urlpatterns = patterns('', > > > > > > > (r'^$', 'proj.app.views.index'), > > > > > > > (r'^admin/(.*)', admin.site.root), > > > > > > > (r'^media/(?P<path>.*)$', 'django.views.static.serve', > > > > > > > {'document_root': settings.MEDIA_ROOT}), > > > > > > > ) > > > > > > > > In my settings.py i have (among other things): > > > > > > > import os > > > > > > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__) > > > > > > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media') > > > > > > > MEDIA_URL = 'http://127.0.0.1:8000/media/' > > > > > > > ADMIN_MEDIA_PREFIX = 'adminmedia' > > > > > > > > my directory structure in windows is: > > > > > > > > c:\dev > > > > > > > -\proj > > > > > > > __init__.py > > > > > > > manage.py > > > > > > > settings.py > > > > > > > urls.py > > > > > > > -\app > > > > > > > -__init__.py > > > > > > > -admin.py > > > > > > > -models.py > > > > > > > -views.py > > > > > > > -\adminmedia > > > > > > > -\media > > > > > > > -\css > > > > > > > -styles.css > > > > > > > -\images > > > > > > > -\templates > > > > > > > -base.html > > > > > > > -index.html > > > > > -- > > > > If you spin an oriental man, does he become disoriented? > > > > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu > > > > > is der net süß » ε(●̮̮̃•̃)з > > > > -----PM > > > -- > > If you spin an oriental man, does he become disoriented? > > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu > > > is der net süß » ε(●̮̮̃•̃)з > > -----PM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---