[GSOC 2024] Auto-importing in the shell

I think the current output already aligns closely with this suggestion since it includes the module name. For example, in the case of ModelA, it would print something like from myapps.models import ModelA. Does this meet your expectations, or is there a specific tweak you’d like to see?

I agree, I think this is good
I wasn’t sure if the suggestion to update the -v 2 output was asking for the paths to be removed

It wasn’t the intention to remote the paths, sorry for the confusion in how I presented the proposal. But I would like the list to be intended one level in so it’s clearly visible what’s the “phrase/intro” and what’s the list.

A quick update on this topic: I’m making progress with the PR review and adding some minor tweaks to the output. After trying several options, what I’m showing below is what I prefer so far. Please feel free to share comments or suggest small adjustments, but let’s keep the feedback focused so we can converge on a final solution and ideally merge it this week.

4 Likes

This feature is now available in Django main, please give it a spin if you can!

7 Likes

Hey There,

I just explored the shell imports, and you’ve done an amazing job :clap:
I’m planning to share this on my LinkedIn with a detailed description to highlight your great work. :tada:

Suggestions:
Based on my experience with Django development, we typically use the shell to perform or test operations on models. It might be helpful to auto-import commonly used database functions like Count, Sum, F, and Q for quicker access.

Additionally, since most Django projects configure a custom User model, it would be more versatile to import the get_user_model function instead of the default User model.

Thanks,
Ammar Munir

Thank you @Ammar-Munirr, the extra imports that you are suggesting were discussed (and at some point will get implemented) in Default automatic imports in the shell.

1 Like