[Django] #32348: Error description of Django document in "tutorial07"

52 views
Skip to first unread message

Django

unread,
Jan 12, 2021, 11:57:55 PM1/12/21
to django-...@googlegroups.com
#32348: Error description of Django document in "tutorial07"
-----------------------------------------+------------------------
Reporter: Guan | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
[https://docs.djangoproject.com/en/3.1/intro/tutorial07/#writing-your-
first-django-app-part-7 writing-your-first-django-app-part-7]

There is a description: **Note that you can’t remove the original three
slots. **

But I find that ''the original three slots''** is able to** be removed in
Django 3.1.5. The code is as follows:

{{{
# polls.models.py

class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField(verbose_name="date published")

def __str__(self):
return self.question_text

def was_published_recently(self):
now = timezone.now()
return now >= self.pub_date >= now - datetime.timedelta(days=1)


class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)

def __str__(self):
return self.choice_text
}}}


{{{
# polls.admin.py

class ChoiceInline(admin.StackedInline):
model = Choice
extra = 3


class QuestionAdmin(admin.ModelAdmin):
# fields = ["pub_date", "question_text"]
fieldsets = [
(None, {"fields": ["question_text"]}),
("Date Information", {"fields": ["pub_date"]})
]
inlines = [ChoiceInline]


admin.site.register(Question, QuestionAdmin)
}}}

The image url is: https://s3.ax1x.com/2021/01/13/stTQWq.png).

--
Ticket URL: <https://code.djangoproject.com/ticket/32348>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 12, 2021, 11:59:31 PM1/12/21
to django-...@googlegroups.com
#32348: Error description of Django document in "tutorial07"
-------------------------------+--------------------------------------

Reporter: Guan | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Guan):

* component: Uncategorized => Documentation


--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:1>

Django

unread,
Jan 13, 2021, 12:01:46 AM1/13/21
to django-...@googlegroups.com
#32348: Error description of Django document in "tutorial07"
-------------------------------+--------------------------------------

Reporter: Guan | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Guan):

* Attachment "Snipaste_2021-01-13_12-48-24.png" added.

Django

unread,
Jan 13, 2021, 12:02:45 AM1/13/21
to django-...@googlegroups.com
#32348: Error description of Django document in "tutorial07"
-------------------------------+--------------------------------------

Reporter: Guan | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Guan:

Old description:

New description:

[https://docs.djangoproject.com/en/3.1/intro/tutorial07/#writing-your-
first-django-app-part-7 writing-your-first-django-app-part-7]

{{{
# polls.models.py

def __str__(self):
return self.question_text

def __str__(self):
return self.choice_text
}}}


{{{
# polls.admin.py


admin.site.register(Question, QuestionAdmin)
}}}

The image is:
[[Image(Snipaste_2021-01-13_12-48-24.png)]]

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:2>

Django

unread,
Jan 13, 2021, 4:34:33 AM1/13/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
---------------------------------+------------------------------------
Reporter: Guan | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* severity: Normal => Release blocker
* cc: Carlton Gibson (added)
* component: Documentation => contrib.admin
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Thanks for this report. This is not an issue in docs by a regression in
24e540fbd71bd2b0843e751bde61ad0052a811b3 (see #29087). Deleting inlines
added with `extra` should not be possible.

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:3>

Django

unread,
Jan 13, 2021, 6:50:22 PM1/13/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned

Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:4>

Django

unread,
Jan 13, 2021, 8:18:50 PM1/13/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

I just created an [https://github.com/django/django/pull/13888 initial
draft patch] which is not working. I will complete it soon.

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:5>

Django

unread,
Jan 14, 2021, 6:18:49 PM1/14/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:6>

Django

unread,
Jan 14, 2021, 6:19:44 PM1/14/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

Now it is ready for review. I am not sure about the logic in
`toggleDeleteButtonVisibility` function

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:7>

Django

unread,
Jan 15, 2021, 12:42:55 PM1/15/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Guan):

Replying to [comment:7 Hasan Ramezani]:


> Now it is ready for review. I am not sure about the logic in
`toggleDeleteButtonVisibility` function

Hi! Thanks for your work. But there are probably two slight flaws I think:
1. When ValidationError is raised, it's no 'X' at the top right of form.
That the UX is not comfortable is ticket #29087 talked about.
2. For {{{toggleDeleteButtonVisibility}}} function, my option comes from
[https://docs.djangoproject.com/en/3.1/intro/tutorial07/ **extra** form
could not be removed] and
[https://docs.djangoproject.com/en/3.1/topics/forms/formsets/ if a formset
contains no data, then extra + min_num empty forms will be displayed]. So
the calculation I think is:
{{{
const isFormOverload = function() {
const totalFormNum = ~~totalForms.val();
const initialFormNum = ~~initialForms.val();
const minFormNum = ~~minForms.val();
const extraFormNum = ~~extraForms.val();

const emptyFormNum = totalFormNum - initialFormNum;
if (initialFormNum >= emptyFormNum) {
return emptyFormNum > extraFormNum;
}
return emptyFormNum > extraFormNum + minFormNum - initialFormNum;
}
}}}

When {{{isFormOverload}}} returns true, all forms show 'X'.

I created patch [https://github.com/hramezani/django/pull/1 PR] and I'd
like to know your option.

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:8>

Django

unread,
Jan 15, 2021, 1:25:15 PM1/15/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

Thanks Guan for the new calculation. I added your patch to my PR as
separate commiet

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:9>

Django

unread,
Jan 26, 2021, 3:30:01 AM1/26/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned
Component: contrib.admin | Version: 3.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

Reviewing, I think we just missed a doc change with
24e540fbd71bd2b0843e751bde61ad0052a811b3. I've suggest a
[https://github.com/django/django/pull/13936 new PR] making that change.

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:10>

Django

unread,
Jan 26, 2021, 5:19:50 AM1/26/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Carlton
| Gibson
Type: Bug | Status: assigned

Component: Documentation | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: Hasan Ramezani => Carlton Gibson
* component: contrib.admin => Documentation
* severity: Release blocker => Normal
* stage: Accepted => Ready for checkin


Comment:

Having conferred with Mariusz, we will go with the documentation change.
Thanks all.

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:11>

Django

unread,
Jan 27, 2021, 2:44:55 AM1/27/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson <carlton@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f4272d000af598018247fe9687dac0fd02a29a7c" f4272d00]:
{{{
#!CommitTicketReference repository=""
revision="f4272d000af598018247fe9687dac0fd02a29a7c"
Fixed #32348, Refs #29087 -- Corrected tutorial for updated deleting
inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:12>

Django

unread,
Jan 27, 2021, 2:48:12 AM1/27/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"4dbbe3747955cbecbf3668c93a0c885562f063ac" 4dbbe37]:
{{{
#!CommitTicketReference repository=""
revision="4dbbe3747955cbecbf3668c93a0c885562f063ac"
[3.2.x] Fixed #32348, Refs #29087 -- Corrected tutorial for updated
deleting inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.

Backport of f4272d000af598018247fe9687dac0fd02a29a7c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:13>

Django

unread,
Jan 27, 2021, 2:48:40 AM1/27/21
to django-...@googlegroups.com
#32348: Deleting "extra" inlines in admin should not be possible.
-------------------------------------+-------------------------------------
Reporter: Guan | Owner: Carlton
| Gibson
Type: Bug | Status: closed
Component: Documentation | Version: 3.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson <carlton.gibson@…>):

In [changeset:"fa203f17591d53178c28b20f9ad337812666445d" fa203f17]:
{{{
#!CommitTicketReference repository=""
revision="fa203f17591d53178c28b20f9ad337812666445d"
[3.1.x] Fixed #32348, Refs #29087 -- Corrected tutorial for updated
deleting inlines UI.

Updated tutorial to match change in
24e540fbd71bd2b0843e751bde61ad0052a811b3
allowing deletion of original extra inlines.

Backport of f4272d000af598018247fe9687dac0fd02a29a7c from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32348#comment:14>

Reply all
Reply to author
Forward
0 new messages