Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 1, 2010 12:41:42

Emanuel V.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

problem with media


Hi all!

I've recently updated my django version and now all my projects doesn't have
css and js from admin or from my apps

I've started new projects and it simply doesn't work

I've googled and I find out when we are using the deveopment server the
static files from admin should be server automatticly and yet doesn't work.

>From my own apps I'm using the django.contrib.staticfiles app and my old
code doesn't work.

My settings.py have this code:

import os
PROJECT_ROOT = os.path.dirname(__file__)
ROOT_DIR = os.path.dirname(PROJECT_ROOT)
...
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/s/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/s/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
...
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
...
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
)
...

My urls.py have this code:
urlpatterns += staticfiles_urlpatterns()

#This was the old version:
#if settings.DEBUG:
#urlpatterns += patterns('django.contrib.staticfiles.views',
#(r'^%s(?P<path>.*)' % settings.STATIC_URL, 'serve',
{'document_root': 'sss'}),#settings.STATIC_ROOT
#)


Before I realized that the admin was also with the same problem, I've edited
the django.contib.static.serve where I put a print statement like this:
print "%s -- %s" $ (path, document_root)
The result was:
/css/main.css -- None
I guess that the var document_root it's not being sent. I don't know...

Thanks in advanced

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 21st of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support