Re: Layout and global.css files

2012-08-22 Thread Gregory Strydom


Thanks very much for the replies, this really helps alot!

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



Re: Layout and global.css files

2012-08-22 Thread Mike Dewhirst

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 %}href="/static/css/darker.css" />{% endblock %}

{% block branding %}
{% trans 'X Administration' %}
{% 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.



Re: Layout and global.css files

2012-08-22 Thread Melvyn Sopacua
On 23-8-2012 3:41, 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.

You shouldn't edit anything there - it will be lost when you upgrade.
The base procedure is described here:


For the css and js bits, read these top to bottom:



The short version is to copy the files to the appropriate location
whether it be the TEMPLATE_DIRS or STATIC_ROOT and edit those files. The
long version is that you should thoroughly understand how static files
work - it's a recurring issue on the list and it's one of those things
that has to sink in and then you get it. If you don't get it, then lots
of time and energy is wasted on "trying if this works".

-- 
Melvyn Sopacua

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



Re: Layout and global.css files

2012-08-22 Thread Jeff Tchang
I see some stuff under:

/python/lib/python2.6/site-packages/django/contrib/admin/static/admin/css


On Wed, Aug 22, 2012 at 6:41 PM, Gregory Strydom <
gregory.strydom...@gmail.com> 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.
>
> 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.



Layout and global.css files

2012-08-22 Thread Gregory Strydom
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.

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.