diff options
| author | Salvo Polizzi <101474753+salvo-polizzi@users.noreply.github.com> | 2025-01-09 17:00:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-09 13:00:29 -0300 |
| commit | fc28550fe4e0582952993976edc62971bd5345a8 (patch) | |
| tree | caf9428df753d1266dec97cffb3d4571cceacab7 /docs/intro | |
| parent | 8c118c0e00846091c261b97dbed9a5b89ceb79bf (diff) | |
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.
Diffstat (limited to 'docs/intro')
| -rw-r--r-- | docs/intro/tutorial02.txt | 6 | ||||
| -rw-r--r-- | docs/intro/tutorial05.txt | 1 |
2 files changed, 2 insertions, 5 deletions
diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index d43c82c5d2..6a87d2d01c 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -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?>]> diff --git a/docs/intro/tutorial05.txt b/docs/intro/tutorial05.txt index 921670aa5e..219b7b3130 100644 --- a/docs/intro/tutorial05.txt +++ b/docs/intro/tutorial05.txt @@ -150,7 +150,6 @@ whose date lies in the future: >>> import datetime >>> from django.utils import timezone - >>> from polls.models import Question >>> # create a Question instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? |
