Opened 5 hours ago

Last modified 48 minutes ago

#36252 assigned Bug

Duplicate Display of Imports in Django Shell

Reported by: Raffaella Owned by: hesham hatem
Component: Core (Management commands) Version: 5.2
Severity: Normal Keywords: shell
Cc: Raffaella Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When customizing the automatic imports into the shell by adding the same import twice:

from django.core.management.commands import shell


class Command(shell.Command):
    def get_auto_imports(self):
        return super().get_auto_imports() + [
            "django.urls.reverse",
            "django.urls.reverse",
        ]

After opening the shell, while the total number of imports is correct, the reverse import is displayed twice in the output:

12 objects imported automatically:

  from project.newsletter.models import SubscriptionNotification, Subscription, Post, Category
  from django.contrib.sessions.models import Session
  from django.contrib.sites.models import Site
  from django.contrib.contenttypes.models import ContentType
  from django.contrib.auth.models import User, Group, Permission
  from django.contrib.admin.models import LogEntry
  from django.urls import reverse, reverse

Change History (2)

comment:1 by hesham hatem, 2 hours ago

Owner: set to hesham hatem
Status: newassigned

comment:2 by hesham hatem, 48 minutes ago

Has patch: set
Note: See TracTickets for help on using tickets.
Back to Top