There's one very good reason why Django (and any other framework / CMS
worth it's salt) deliberately avoids serving static files, and that
reason is "performance".

Your content serving mechanism should be about retrieving and
manipulating content data, and performance can be haevily impacted if
a system is asked to serve up static content aswell.  Even systems
which hold media files in a database tend to have a caching layer
which serves synchronised media files.

The core principle is: serve dynamic content from one place, serve
static media files from another.  At the simplest level, this can be
two web servers running on a single machine.  At the extreme level, it
can mean having media server clusters.

So in that respect, this is not a "bug" unique to Django - it's an
accepted practice which I think you'll find MSN using.

I can't quite grasp the problem you're having here (perhaps I'm
ovelooking something).  Why can you not just use absolute URLs?  Why
not just use /media/css/my.css?  Or if you're in need of a way to set
a global path, add a new setting to your settings.py file which you
can then import and use in your templates?

Seems to me (and like I say: maybe I'm missing something) that you're
going a very long way round to solve a simple problem.

On 24/05/06, Wilson Miner <[EMAIL PROTECTED]> wrote:
>
> Is there a particular reason you can't just use the full media url in
> your templates? ie. "http://media.coolsite.com/files/css/shadow.css";
> instead of "../css/shadow.css"?
>
> On 5/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > I'm building a CMS for my internal use... I own a web development &
> > desing company... we have experience in ASP.NET but I'm looking for
> > something more "ligth" and come to django... For people with deadlines:
> > that are we!
> >
> > Despite the fact I see how django is productive in a lot of areas, I
> > get bloked in how somethings are done..
> >
> > For example, the "feature" of not serve static files. The worst? I
> > don't can relly in the available workarounds to this "feature" (yeah I
> > put "feature" for be sarcasting... I understand the reason, the why,
> > but be patiente: I have a deadline too and this experiment is taking
> > more than expected!!)
> >
> > I have the fallback of the serve static documentation... but this is
> > not working for me (0.95 + dev web server + win 2003)
> >
> > And anyway this is not good for real work. So:
> >
> > I have two desirable ideas:
> >
> > 1- Use a tag and inject the MEDIA_URL here: (I don't like the
> > suggestion to mess with the template system... to much code)
> >
> > {% BaseUrl %}/css/sample.css
> >
> > I put a templetetag/jhonWebInjector.py dir under my project, then under
> > my core app, then under my specific app.
> >
> > I do this:
> >
> > "Etiquetas estandar de jhonWeb."
> >
> > from django.template import Node, NodeList, Template, Context,
> > resolve_variable
> > from django.template import TemplateSyntaxError, VariableDoesNotExist,
> > BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END
> > from django.template import get_library, Library,
> > InvalidTemplateLibrary
> > from django.conf import settings
> > import sys
> >
> > register = template.Library()
> >
> > class BaseUrl(template.Node):
> >     def __init__(self):
> >         pass
> >
> >     def render(self, context):
> >         context['BaseUrl'] = 'uno'
> >         return ''
> >
> > def do_get_BaseUrl(parser, token):
> >     """
> >     {% BaseUrl %}
> >     """
> >     return 'uno'
> >
> > register.tag('BaseUrl', do_get_BaseUrl)
> >
> > and in the template:
> >
> > {% load "jhonWebInjector" %}
> > {{ BaseUrl }}
> >
> > But say:
> >
> > '"jhonWebInjector"' is not a valid tag library: Could not load template
> > library from django.templatetags."jhonWebInjector", No module named
> > "jhonWebInjector"
> >
> > However... this is a HACK. I don't like to say to my designers: Look
> > dude, I chose a development framework, and have this beautifull
> > template thing that break the use of any web desing editor like
> > dreamweaver or topstylebecause is necesary put this little hack, so you
> > not can see in realtime what is happening with your ... errr... desing
> >
> > 2- However, I'm thinking in the lines of the dotnetnuke people: This
> > tool have a "install template" thing that convert a .html template in a
> > .ascx module and put the rigth paths to the images and css and
> > javascript.
> >
> > So, my ideas is do this way:
> >
> > The way is done under a local environment, like topstyle:
> >
> > <link rel="stylesheet" type="text/css" href="../css/shadow.css" />
> >
> > And do some magic to the response (where, how? a middleware?) to look
> > for paths with a regex, and auto-magically turn it in:
> >
> > <link rel="stylesheet" type="text/css"
> > href="http://media.coolsite.com/files/css/shadow.css"; />
> >
> > The 1) is a nice hack by now but I like to know if is possible do in
> > the fly the 2)
> >
> > I think this is the way if is expected that normal web designers build
> > the front-end of the system...
> >
> > I talk with my designers and think is not that bad use a "template
> > language" if that mean total freedom to desing (in contrast to *nuke
> > CMS, I mean). But is a total requeriment to see what is happening with
> > the css/images/etc.. in desing mode...
> >
> >
> > >
> >
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to