Django Admin static base.css ignored

895 views
Skip to first unread message

Lee

unread,
May 27, 2011, 3:04:03 PM5/27/11
to Django users
I've customized myproject/static_files/admin/css/base.css but my
customizations are ignored. If I make changes to /usr/lib/python2.4/
site-packages/django/contrib/admin/media/css/base.css it works fine.
I've double-checked the STATIC settings in settings.py and all looks
correct. Any ideas?

Thanks for any help.

Lee

Daniel Roseman

unread,
May 27, 2011, 3:16:41 PM5/27/11
to django...@googlegroups.com
How are you telling Django about your overridden CSS? Are you specifying it in the ModelAdmin class, or in an overridden template?

I hope you're not expecting it to be picked up automatically, as there's nothing in the documentation to imply that is the case.
--
DR.

Lee

unread,
May 27, 2011, 4:20:35 PM5/27/11
to Django users
> How are you telling Django about your overridden CSS? Are you specifying it
> in the ModelAdmin class, or in an overridden template?
>
> I hope you're not expecting it to be picked up automatically, as there's
> nothing in the documentation to imply that is the case.
> --
> DR.

Well, collectstatic copied the base.css to myproject/static_files/
admin/css/base.css, and if I inspect elements on the Admin pages with
Firebug they are styled by http://myprojectdomain:8000/static/admin/css/base.css,
so it looks like everything is hooked up.

Lee

unread,
Jun 1, 2011, 6:32:25 PM6/1/11
to Django users
This worked for me:

settings.py
--------------
STATIC_ROOT = '/path_to_my_project/static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = ('/path_to_my_project/css/',)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

myproject/admin.py
-------------------------
class MyAdminClass(admin.ModelAdmin):
class Media:
css = {
"all": ("myproject.css",)
}

class Entity1Admin(MyAdminClass):
...

----------
Then put custom css in /path_to_my_project/css/myproject.css

References:
https://docs.djangoproject.com/en/dev/releases/1.3/#extended-static-files-handling
https://docs.djangoproject.com/en/dev/howto/static-files/
Reply all
Reply to author
Forward
0 new messages