Skip to content

Fixed #35680 -- Added default automatic imports to shell.#18560

Merged
sarahboyce merged 1 commit intodjango:mainfrom
salvo-polizzi:ticket_35680
Jul 17, 2025
Merged

Fixed #35680 -- Added default automatic imports to shell.#18560
sarahboyce merged 1 commit intodjango:mainfrom
salvo-polizzi:ticket_35680

Conversation

@salvo-polizzi
Copy link
Copy Markdown
Contributor

@salvo-polizzi salvo-polizzi commented Sep 9, 2024

Trac ticket number

ticket-35680

Branch description

Builds on top of #18158 which must be merged first.

Added default automatic imports to shell following this discussion.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@salvo-polizzi salvo-polizzi changed the title Ticket 35680 Fixed #35680 -- Added default automatic imports to shell Sep 9, 2024
@salvo-polizzi salvo-polizzi changed the title Fixed #35680 -- Added default automatic imports to shell Fixed #35680 -- Added default automatic imports to shell. Sep 9, 2024
Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for picking this up @salvo-polizzi

This is missing doc updates 👍

@salvo-polizzi
Copy link
Copy Markdown
Contributor Author

Thank you for picking this up @salvo-polizzi

This is missing doc updates 👍

Hi @sarahboyce, do you think it would be better to add this as a note in the shell section of django-admin reference, or were you thinking of something else?

@sarahboyce
Copy link
Copy Markdown
Contributor

do you think it would be better to add this as a note in the shell section of django-admin reference, or were you thinking of something else?

Basically all docs that were updated in the previous commit refer to the models as the only thing auto imported. All of these references would need updating

@salvo-polizzi salvo-polizzi force-pushed the ticket_35680 branch 2 times, most recently from d93fb68 to 2bb6a07 Compare September 19, 2024 07:13
@salvo-polizzi salvo-polizzi force-pushed the ticket_35680 branch 2 times, most recently from 475d54c to 5bdf927 Compare February 14, 2025 11:23
Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for updating the PR @salvo-polizzi

docs/howto/custom-shell.txt needs to be updated as it mentions that only models are what are imported by default, I feel we should be more general such as "plus what is imported by default as described by "

We are missing a release note in 6.0 👍

@salvo-polizzi
Copy link
Copy Markdown
Contributor Author

Hi @sarahboyce,

Thank you for your review! 👍

I've made some updates to the documentation:

  • Release Notes (6.0): Added a brief release note.
  • custom_shell.txt: Clarified that, in addition to models, the default imports are also mentioned.
  • Django-admin.txt: Included a .. versionchanged:: 6.0 note listing the default imports.

Please let me know if I missed anything or if there’s anything you'd like me to refine.

Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the updates!

Comment on lines 60 to 56
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would update assuming isort is installed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, my bad 👍

@sarahboyce
Copy link
Copy Markdown
Contributor

@salvo-polizzi just so you are aware of my current thoughts, I am reluctant to merge anything until at least 2 months after the 5.2 final release. I would like us to receive some user feedback on the auto imports before we build on top of it

@salvo-polizzi
Copy link
Copy Markdown
Contributor Author

@salvo-polizzi just so you are aware of my current thoughts, I am reluctant to merge anything until at least 2 months after the 5.2 final release. I would like us to receive some user feedback on the auto imports before we build on top of it

Sure, let's keep this for later discussions when we have a greater consensus and feedback about this.

Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note we did an update in de1117e which added tests.shell.tests.ShellCommandTestCase.test_no_settings, I think it's worth adding an assert to confirm that these are not imported to the namespace

@salvo-polizzi
Copy link
Copy Markdown
Contributor Author

Note we did an update in de1117e which added tests.shell.tests.ShellCommandTestCase.test_no_settings, I think it's worth adding an assert to confirm that these are not imported to the namespace

Thank you @sarahboyce for pointing out this 👍

@salvo-polizzi
Copy link
Copy Markdown
Contributor Author

Hi @sarahboyce, thank you for the review ⭐ (It's good to hear from you)!

@salvo-polizzi salvo-polizzi requested a review from sarahboyce June 6, 2025 07:36
Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I have a few minor suggestions around the release/version changed notes and then I think this looks good to me 👍

@salvo-polizzi salvo-polizzi force-pushed the ticket_35680 branch 2 times, most recently from 31c16da to 68565ea Compare June 25, 2025 13:30
Copy link
Copy Markdown
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks good to me

@sarahboyce sarahboyce merged commit a5cd84a into django:main Jul 17, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants