Monday, October 22, 2012

Re: Struggling with static files

Give path to your STATIC_ROOT of your static folder.


Pervez

On Mon, Oct 22, 2012 at 2:26 PM, DJ-Tom <eventellis@gmail.com> wrote:
Hi,

I'm fairly new with Django and currently I'm only "playing around" to get a better feeling for the framework.

I have read the documentation and almost all of the posts here about configuring static files with the development server but can't get it working.

I wanted to modify the admin login screen to show a company logo, so I copied base_site.html to /templates/admin/ and added this:

   <img src="{{ STATIC_URL }}logo.gif" />


This is how my directory structure looks like:

el_test
  el_test
    static
       logo.gif
    settings.py
    urls.py
  templates
    admin
      base_site.html

- Settings.py:

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

I also added the following to urls.py

   urlpatterns += staticfiles_urlpatterns()

The HTML in the admin logon screen looks like this, so basically the URL seems to be OK

<div id="branding">
  <img src="/static/logo.gif">
  <h1 id="site-name">Test Admin</h1>
</div>


Calling http://localhost:8000/static/logo.gif directly shows a 404 error.

As far as I have understood this should work with the dev server and debug=true without calling collectstatic

I have also tried moving the /static/ folder around various locations below the project directory...

I'm sure there is only some small thing missing...

Any help is highly appreciated :-)

Thomas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/YqVkguDtVwEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment