[Django] #30036: Code example for using Paginator in a view makes redundant imports

1 view
Skip to first unread message

Django

unread,
Dec 12, 2018, 11:07:49 AM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
------------------------------------------------+------------------------
Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.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 |
------------------------------------------------+------------------------
The code example in this section:
[https://docs.djangoproject.com/en/2.1/topics/pagination/#using-paginator-
in-a-view Using Paginator in a view] imports `EmptyPage` and
`PageNotAnInteger` unnecessarily since `Paginator.get_page()` handles
these exceptions internally.

I had to spend some time figuring out why these were imported and never
used. I even thought the code example might be incomplete, until I checked
the source code.

I think it's better to remove these imports as they leave the reader
confused.

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

Django

unread,
Dec 12, 2018, 11:22:46 AM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
--------------------------------------+------------------------------------

Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.1
Severity: Normal | 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 Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

Yep. Thanks. Would you like to make a PR for these changes, whilst they're
fresh in your mind?

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

Django

unread,
Dec 12, 2018, 11:34:17 AM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
--------------------------------------+------------------------------------

Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.1
Severity: Normal | 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 Greg W):

I'll take it if OP doesn't want to do it.

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

Django

unread,
Dec 12, 2018, 11:50:00 AM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
--------------------------------------+------------------------------------

Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 2.1
Severity: Normal | 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 Carlton Gibson):

Thanks Greg. I already have a patch ready. I just wanted to see if the OP
wanted to make a contribution...

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

Django

unread,
Dec 12, 2018, 12:50:33 PM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
--------------------------------------+------------------------------------
Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.1
Severity: Normal | Resolution: fixed
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 GitHub <noreply@…>):

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


Comment:

In [changeset:"a394289b58b1773c4959ed768fdb325c91b2b589" a394289b]:
{{{
#!CommitTicketReference repository=""
revision="a394289b58b1773c4959ed768fdb325c91b2b589"
Fixed #30036 -- Removed unused imports in pagination example.
}}}

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

Django

unread,
Dec 12, 2018, 12:51:44 PM12/12/18
to django-...@googlegroups.com
#30036: Code example for using Paginator in a view makes redundant imports
--------------------------------------+------------------------------------
Reporter: bhch | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Documentation | Version: 2.1

Severity: Normal | Resolution: fixed
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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"8d741bd88fa6bd14327f6fa791017d0773b41cf2" 8d741bd]:
{{{
#!CommitTicketReference repository=""
revision="8d741bd88fa6bd14327f6fa791017d0773b41cf2"
[2.1.x] Fixed #30036 -- Removed unused imports in pagination example.

Backport of a394289b58b1773c4959ed768fdb325c91b2b589 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages