On 23/08/2012 11:41am, Gregory Strydom wrote:
Could anyone perhaps tell me where i could find the layout.css and
global.css for the base admin site?
Ive tried looking through C:/Python26/site-packages/django but cant seem
to find anything. What i am trying to do is just change colour where it
say Users, Groups, Sites etc in the django admin. I managed to change
the header colors so far but was told i need to edit layout and
global.css to change the other colors.
I have solved this in a cack-handed way and would like to learn how to
do it correctly.
I had trouble getting my own css files to work in the admin overriding
the contrib.admin styles because the admin base.css kept being used
instead of mine when I used the extrastyle block. Here is my
base_site.html template ...
{% extends "admin/base.html" %}
{% load i18n %}
{% block title %}{{ title }} | {% trans 'X' %}{% endblock %}
{% block extrastyle %}{% endblock %}
{% block userstyle %}<link rel="stylesheet" type="text/css"
href="/static/css/darker.css" />{% endblock %}
{% block branding %}
<h1 id="site-name">{% trans 'X Administration' %}</h1>
{% endblock %}
{% block nav-global %}{% endblock %}
{% block extrahead %}{% endblock %}
You can see the "foreign" userstyle block there. That is where I had to
put my css to get it used in the right cascade sequence over the top of
the real thing. I think the extrastyle block is for extra styles rather
than replacement styles.
I wrote a script to patch the admin base.html to insert that userstyle
block and that works. But adjusting the admin base.html is not nice.
Hence I would like to discover how it should be done.
Here is my patch_admin_base.py script ...
"""
patch django-admin base.html to include a userstyle block
"""
project = "x"
srvroot = "/srv/www"
vws_root = "%s/%s" % (srvroot, project)
app_root = "%s/%s" % (vws_root, project)
import os
import sys
if app_root not in sys.path:
sys.path.insert(0, app_root)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % project)
from django.contrib import admin
flag = '{% block extrastyle %}{% endblock %}'
patch1 = '{# userstyle inserted by md #}\n'
patch2 = '{% block userstyle %}{% endblock %}\n'
base_template = 'templates/admin/base.html'
done = False
pth =
os.path.split(str(admin).split()[-1].split("'")[-2].replace("\\","/"))[0]
template = '%s/%s' % (pth, base_template)
if os.path.isfile(template):
lines = list()
with open(template, "r") as base:
lines = base.readlines()
done = patch2 in lines
if not done:
with open(template, "w") as base:
for line in lines:
base.write(line)
if flag in line:
base.write(patch1)
base.write(patch2)
done = True
if done:
print('\n%s patched' % template)
else:
print('\n%s not patched' % template)
else:
print('\n%s already patched' % template)
else:
print('\nbase.html not found')
Thanks very much for any help with this!
--
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/-/N9aDIJzmHngJ.
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.
--
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.