On 6 май, 04:41, Reinout van Rees <rein...@vanrees.org> wrote:
> On 05-05-12 15:34, e.generalov wrote:
>
> > There was a snippet to display a content of response in browser during
> > debugginghttp://miniblog.glezos.com/post/3388080372/tests-browser .
>
> > "One of the first issues you might face is seeing a style-less page.
> > This happens becuase the test server isn t really a web server, and
> > you re probably serving static files from something relative such as
> > '/
> > site_media'. The solution is simple: Run a separate Django server and
> > tweak your development-only static URL to something like:
>
> > STATIC_URL = 'http://localhost:8000/site_media/
> > "
>
> > but this doesn't works anymore, because django.contrib.staticfiles
> > doesn't serve static when STATIC_URL contains full URL.
>
> I don't have any problems with static stuff. The solution is probably
> simply to not include any hostname. What I have (on the server and
> locally on my development box):
>
> STATIC_URL = '/static_media/'

In order for static files at the temporary saved page,
become accessible to the browser,
them urls must be a full.

-- /tmp/pageXXXXXXX.html --

<img src="http://localhost:8080/static/img.png";>

(this suggestion has discribed at the sinppet's page).

>
> In case it still doesn't work: you probably use something else than the
> standard runserver. In that 
> case,https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#django...
> applies. You have to add that to your urls.py. But normally, you don't
> have to.

I see the code at 
https://github.com/django/django/blob/master/django/contrib/staticfiles/handlers.py#L31
, and it looks like
the STATIC_URL checking logic is hardcoded to the handler.

When `django.contrib.staticfiles` is added to INSTALLED_APPS, it
overrides the standard `runserver` command and use
specialized WSGIHandler to serve static files. It is not possible to
change any behavior of this handler with standard
django's request handling tools (urls.py, middlewares, views), because
handler works before them all.


>
> Reinout
>
> --
> Reinout van Rees                    http://reinout.vanrees.org/
> rein...@vanrees.org            http://www.nelen-schuurmans.nl/
> "If you're not sure what to do, make something. -- Paul Graham"

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

Reply via email to