Admin css question for 1.10.7

38 views
Skip to first unread message

Mike Dewhirst

unread,
May 7, 2017, 3:05:14 AM5/7/17
to Django users
I'm just (slowly) advancing from 1.8 to 1.11 and stopping for a short
while at 1.10.

I notice that help-text doesn't line up under the left edge of
DecimalField fields the way it does for TextFields and most others.

Is this a deliberate design decision?

Thanks

Mike


--
PLEASE NOTE OUR NEW LANDLINE IS +61 (0)3 9034 3977

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9034 3977
M: 0411 704 143


Tim Graham

unread,
May 7, 2017, 10:12:17 AM5/7/17
to Django users
You can use git bisect to find the Django commit where the behavior changed:
https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#bisecting-a-regression

Mike Dewhirst

unread,
May 7, 2017, 12:18:56 PM5/7/17
to django...@googlegroups.com
On 7/05/2017 8:12 PM, Tim Graham wrote:
> You can use git bisect to find the Django commit where the behavior
> changed:
> https://docs.djangoproject.com/en/dev/internals/contributing/triaging-tickets/#bisecting-a-regression

Just read this and I have two problems ...

1. It is a css problem resulting in help-text which is stepped in by
200px versus 160px and I can adjust that in the css file to make
everything line up again. However, the real problem here is I don't know
how to write a test for that.

2. I have (so far) no use for github and zero competence therein. I use
svn.

The workaround for problem 2 is to start looking backwards from 1.10.7
to see if I can visually inspect the css files. I can install different
versions and bisect manually.

However, maybe the change is in the widgets or the forms?

Thanks for any hints if you think that is the case.

Mike

>
> On Saturday, May 6, 2017 at 11:05:14 PM UTC-4, Mike Dewhirst wrote:
>
> I'm just (slowly) advancing from 1.8 to 1.11 and stopping for a short
> while at 1.10.
>
> I notice that help-text doesn't line up under the left edge of
> DecimalField fields the way it does for TextFields and most others.
>
> Is this a deliberate design decision?
>
> Thanks
>
> Mike
>
>
> --
> PLEASE NOTE OUR NEW LANDLINE IS +61 (0)3 9034 3977
>
> Climate Pty Ltd
> PO Box 308
> Mount Eliza
> Vic 3930
> Australia +61
>
> T: 03 9034 3977
> M: 0411 704 143
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/77fb23ef-184d-4887-a3cb-01014a7e0392%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/77fb23ef-184d-4887-a3cb-01014a7e0392%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Mike Dewhirst

unread,
May 8, 2017, 2:01:19 AM5/8/17
to django...@googlegroups.com
Tim

The problem does not exist in 1.8.18 and does exist in 1.9

Here is the test I wrote to see if the css file contains the problem
(which I established by trial and error) ...

# -*- coding: utf-8 -*-
import os
from django.test import TestCase
from django.contrib import admin


expected = "form .wide p, form .wide input + p.help {"


class TestBadCss(TestCase):

def test_bad_css(self):
base_css = 'static/admin/css/forms.css'
exists = False
stradmin = str(admin)
pth = os.path.split(stradmin.split()[-1].split("'")[-2])[0]
base_css = os.path.join(pth, base_css).replace("\\","/")
#print("\n%s" % base_css)
if os.path.isfile(base_css):
lines = list()
with open(base_css, "r") as base:
lines = base.readlines()
for line in lines:
exists = expected in line
if exists:
break
self.assertEqual(exists, False)

I installed git and tried to do the bisecting thing but that didn't work
for me

(xxex3) C:\Users\mike\env\xxex3\ssds>git bisect bad
fatal: Not a git repository (or any of the parent directories): .git

Where should I go next?

Thanks

Mike

On 7/05/2017 8:12 PM, Tim Graham wrote:

Tim Graham

unread,
May 8, 2017, 10:57:01 AM5/8/17
to Django users
You need to clone the Django repository and run the bisect command from there: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/

That said, you might have some luck using the "Blame" button on https://github.com/django/django/blob/stable/1.9.x/django/contrib/admin/static/admin/css/forms.css
That'll take you take a page that shows the latest change for each line.

Melvyn Sopacua

unread,
May 8, 2017, 1:04:19 PM5/8/17
to django...@googlegroups.com

On Monday 08 May 2017 03:57:01 Tim Graham wrote:

> You need to clone the Django repository and run the bisect command

> from there:

 

Simplicity in Unix:

 

1 #!/bin/sh

2

3 # Basically, make grep -qv behave like I want it to

4

5 file='django/contrib/admin/static/admin/css/forms.css'

6 bad='form .wide p, form .wide input + p.help {'

7

8 fgrep -q "$bad" $file

9 if [ $? -eq 0 ]

10 then

11 exit 1

12 else

13 exit 0

14 fi

 

Results:

% git bisect start 2c3c029ede 0b9f366c60

Bisecting: a merge base must be tested

[39d95fb6ada99c59d47fa0eae6d3128abafe2d58] Fixed #24092 -- Widened base field support for ArrayField.

 

% git bisect run `pwd`/invert.sh

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 1196 revisions left to test after this (roughly 10 steps)

[3d650e80ad47fdf3e7758766d2b00ed3c1efb089] Added today's security issues to the archive.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 598 revisions left to test after this (roughly 9 steps)

[672de44e242369d29136bbf1f3ae1059dd787936] [1.9.x] Replaced "inbuilt" with more common "built-in".

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 298 revisions left to test after this (roughly 8 steps)

[e8bfc1c74767ba902846ed0736327ce400112f3c] Stopped returning mirrors from setup_databases.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 149 revisions left to test after this (roughly 7 steps)

[566a01e916a0565db5af8dfb5ac9ce2fafc74c66] [1.9.x] Removed unused views.debug.linebreak_iter() function.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 74 revisions left to test after this (roughly 6 steps)

[b0c56b895fd2694d7f5d4595bdbbc41916607f45] Fixed #24496 -- Added CSRF Referer checking against CSRF_COOKIE_DOMAIN.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 36 revisions left to test after this (roughly 5 steps)

[b1a29541e5d37c03becde6c84e793766ef23395c] Merge pull request #4761 from aaugustin/parallelize-tests-attempt-1

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 18 revisions left to test after this (roughly 4 steps)

[eaa3c883450f3c7ea939992ed075257bbac3d8b2] Refs #22258 -- Fixed an unclosed temporary file in fixtures test.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 8 revisions left to test after this (roughly 3 steps)

[29d52583e77b247aceeb2f514177a8a6c21ed786] Removed 'Test that' prefix from admindocs tests.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 4 revisions left to test after this (roughly 2 steps)

[b929d2d09d24705bc59d1d172921e1feade2777b] Fixed #25200 -- Updated tutorial screenshots for new admin theme.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 1 revision left to test after this (roughly 1 step)

[19f98946f2b31b62303aedb5b30951ca295116d8] Fixed #25358 -- Improved variable name for question in tutorial.

running /home/melvyn/hg/django-project/invert.sh

Bisecting: 0 revisions left to test after this (roughly 0 steps)

[e23e7b2ffe8e282adfd5c597df25c181413c5b3b] Fixed #11544 -- Removed !important rules in contrib.admin styles.

running /home/melvyn/hg/django-project/invert.sh

e23e7b2ffe8e282adfd5c597df25c181413c5b3b is the first bad commit

commit e23e7b2ffe8e282adfd5c597df25c181413c5b3b

Author: elky <manse...@gmail.com>

Date: Mon Sep 7 00:28:14 2015 +0500

 

Fixed #11544 -- Removed !important rules in contrib.admin styles.

 

:040000 040000 8ba07a707a8493e0eed28fd23cb0e0d1b29e4e69 756ac7c45cced7bb403573eb4d31a70c250fddf8 M django

bisect run success

 

 

Happy hunting.

--

Melvyn Sopacua

Mike Dewhirst

unread,
May 9, 2017, 1:47:04 AM5/9/17
to django...@googlegroups.com
Now I get it!

> [e23e7b2ffe8e282adfd5c597df25c181413c5b3b] Fixed #11544 -- Removed
> !important rules in contrib.admin styles.
>
> running /home/melvyn/hg/django-project/invert.sh
>
> e23e7b2ffe8e282adfd5c597df25c181413c5b3b is the first bad commit
>
> commit e23e7b2ffe8e282adfd5c597df25c181413c5b3b
>
> Author: elky <manse...@gmail.com>
>
> Date: Mon Sep 7 00:28:14 2015 +0500
>
> Fixed #11544 -- Removed !important rules in contrib.admin styles.
>

Should I now contact elky and start a conversation?

Thanks Tim and Melvyn

Mike

> :040000 040000 8ba07a707a8493e0eed28fd23cb0e0d1b29e4e69
> 756ac7c45cced7bb403573eb4d31a70c250fddf8 M django
>
> bisect run success
>
> Happy hunting.
>
> --
>
> Melvyn Sopacua
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3834087.V7UGXNyRTa%40devstation
> <https://groups.google.com/d/msgid/django-users/3834087.V7UGXNyRTa%40devstation?utm_medium=email&utm_source=footer>.

Mike Dewhirst

unread,
May 9, 2017, 7:49:48 AM5/9/17
to django...@googlegroups.com, manse...@gmail.com
On 9/05/2017 11:45 AM, Mike Dewhirst wrote:
> On 8/05/2017 11:02 PM, Melvyn Sopacua wrote:
>>
>> On Monday 08 May 2017 03:57:01 Tim Graham wrote:
>>
>> > You need to clone the Django repository and run the bisect command
>>
>> > from there:
>>
>>

snip

>> running /home/melvyn/hg/django-project/invert.sh
>>
>> Bisecting: 0 revisions left to test after this (roughly 0 steps)
>>
>
> Now I get it!
>
>> [e23e7b2ffe8e282adfd5c597df25c181413c5b3b] Fixed #11544 -- Removed
>> !important rules in contrib.admin styles.
>>
>> running /home/melvyn/hg/django-project/invert.sh
>>
>> e23e7b2ffe8e282adfd5c597df25c181413c5b3b is the first bad commit
>>
>> commit e23e7b2ffe8e282adfd5c597df25c181413c5b3b
>>
>> Author: elky <manse...@gmail.com>
>>
>> Date: Mon Sep 7 00:28:14 2015 +0500
>>
>> Fixed #11544 -- Removed !important rules in contrib.admin styles.
>>
>
> Should I now contact elky and start a conversation?

I went back to the docs and saw I should add a comment to ticket #11544.
The ticket has been closed and I couldn't see how to add a new comment.
I suspect closing the ticket cuts off new comments. I'll cc elky and see
what happens.

As a workaround, I've added my own bit of css in {% block extrastyles %}
to adjust margin-left like so ...

form .wide p, form .wide input + p.help {
margin-left: 160px !important;
}

... which seems to work. I'd be happy to see forms.css changed but I
don't know about unintended consequences.

For elky, the symptom is indented help-text in the Admin for
DecimalFields versus help-text for other fields. It seems to be
controlled from forms.css like so ...

form .wide p, form .wide input + p.help {
margin-left: 200px;
}

... and making it 160px seems to repair it. Happy to help in any way
which doesn't involve learning git ;)

Thanks everyone for all your help.

Cheers

Mike

Melvyn Sopacua

unread,
May 9, 2017, 8:37:23 AM5/9/17
to django...@googlegroups.com, manse...@gmail.com

On Tuesday 09 May 2017 17:48:43 Mike Dewhirst wrote:

> On 9/05/2017 11:45 AM, Mike Dewhirst wrote:

> > On 8/05/2017 11:02 PM, Melvyn Sopacua wrote:

> >> On Monday 08 May 2017 03:57:01 Tim Graham wrote:

> >> > You need to clone the Django repository and run the bisect

> >> > command

>

> >> > from there:

> snip

>

> >> running /home/melvyn/hg/django-project/invert.sh

> >>

> >> Bisecting: 0 revisions left to test after this (roughly 0 steps)

> >

> > Now I get it!

> >

> >> [e23e7b2ffe8e282adfd5c597df25c181413c5b3b] Fixed #11544 -- Removed

> >> !important rules in contrib.admin styles.

> >>

> >> running /home/melvyn/hg/django-project/invert.sh

> >>

> >> e23e7b2ffe8e282adfd5c597df25c181413c5b3b is the first bad commit

> >>

> >> commit e23e7b2ffe8e282adfd5c597df25c181413c5b3b

> >>

> >> Author: elky <manse...@gmail.com>

> >>

> >> Date: Mon Sep 7 00:28:14 2015 +0500

> >>

> >> Fixed #11544 -- Removed !important rules in contrib.admin styles.

> >

> > Should I now contact elky and start a conversation?

>

> I went back to the docs and saw I should add a comment to ticket

> #11544. The ticket has been closed and I couldn't see how to add a

> new comment.

 

The ticket is also too old to be necro'd. You can open a new one and reference it. What I'm really surprised about is that this unwanted side-effect went unnoticed for so long. Makes you question how many people use the wide form view.

 

--

Melvyn Sopacua

Reply all
Reply to author
Forward
0 new messages