mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #35515 -- Added automatic model imports to shell management command.
Thanks to Bhuvnesh Sharma and Adam Johnson for mentoring this Google Summer of Code 2024 project. Thanks to Sarah Boyce, David Smith, Jacob Walls and Natalia Bidart for reviews.
This commit is contained in:
parent
8c118c0e00
commit
fc28550fe4
10 changed files with 374 additions and 19 deletions
|
@ -347,13 +347,13 @@ API Django gives you. To invoke the Python shell, use this command:
|
|||
We're using this instead of simply typing "python", because :file:`manage.py`
|
||||
sets the :envvar:`DJANGO_SETTINGS_MODULE` environment variable, which gives
|
||||
Django the Python import path to your :file:`mysite/settings.py` file.
|
||||
By default, the :djadmin:`shell` command automatically imports the models from
|
||||
your :setting:`INSTALLED_APPS`.
|
||||
|
||||
Once you're in the shell, explore the :doc:`database API </topics/db/queries>`:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from polls.models import Choice, Question # Import the model classes we just wrote.
|
||||
|
||||
# No questions are in the system yet.
|
||||
>>> Question.objects.all()
|
||||
<QuerySet []>
|
||||
|
@ -443,8 +443,6 @@ Save these changes and start a new Python interactive shell by running
|
|||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from polls.models import Choice, Question
|
||||
|
||||
# Make sure our __str__() addition worked.
|
||||
>>> Question.objects.all()
|
||||
<QuerySet [<Question: What's up?>]>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue