Avviare python manage.py shell
Apra una shell con il progetto già caricato
Avviare python manage.py shell è una lezione Django Academy gratuita su CoddyKit. Questa è la lezione 1 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Django Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Django Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
A Playground for Your Project
The Django shell is an interactive Python session that already knows about your project, so you can test ideas live without writing a file. 🧪
Why Not Just python?
Plain python can not import your models, because Django settings are not loaded. The shell command wires everything up for you first.
The One Command
You launch it through manage.py, the same script you use for everything else. It loads settings, then drops you into Python.
python manage.py shellRun It from the Project Root
Run the command in the folder that holds manage.py. From there Django can find your settings and apps with no extra setup.
What the Prompt Looks Like
Once it starts, you see the familiar Python prompt with three chevrons. Anything you type runs instantly and shows its result.
>>> 2 + 2
4Settings Are Already Loaded
Because settings are configured, you can read project values right away. Try printing your DEBUG flag to confirm the shell sees them.
>>> from django.conf import settings
>>> settings.DEBUG
TrueImport and Explore
Now any model or utility is one import away. The shell is perfect for poking at code before you commit it to a file.
Multi-Line Blocks Work Too
You are not limited to one-liners. Start a loop or function and the prompt switches to dots until the block is complete.
>>> for i in range(3):
... print(i)Leaving the Shell
When you are done, type exit() or press Ctrl-D to return to your normal terminal. Nothing you typed is saved to disk.
>>> exit()It Is Throwaway by Design
Treat the shell as a scratchpad. It is ideal for experiments, but real changes belong in views, models, or scripts you can rerun.
Database Writes Are Real
One caution: queries hit your real database. Saving an object in the shell changes data for good, so be careful on production.
Quick Check
Why use the Django shell instead of plain python?
Recap
You learned that manage.py shell opens an interactive Python session with your project loaded, perfect for quick experiments before writing real code. 🎉
Domande Frequenti
La lezione «Avviare python manage.py shell» è gratuita?
Sì — il testo completo di «Avviare python manage.py shell» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Django Academy, passa a CoddyKit PRO. Il corso Django Academy include 4 lezioni in totale.
Cosa imparerò in «Avviare python manage.py shell»?
Apra una shell con il progetto già caricato Eserciti Django Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Django Academy?
Non è richiesta alcuna esperienza precedente. Django Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 1 di 4.
Quanto tempo richiede la lezione «Avviare python manage.py shell»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Django Academy?
Sì. Ogni lezione Django Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Avviare python manage.py shell
- Importare e ispezionare i modelli
- Creare e salvare oggetti in tempo reale
- shell_plus e strumenti migliori