Installing Django & Environment Setup
Installing Django & Environment Setup
Django is a high-level Python web framework designed for rapid, secure, and maintainable software engineering. Following the "batteries-included" philosophy, Django ships out of the box with an Object-Relational Mapper (ORM), database migration engine, administrative dashboard, user authentication, and CSRF/XSS security protections.
1. Setting Up an Isolated Virtual Environment
Never install Python web frameworks into your global operating system environment. Dependency version conflicts between packages can break OS-level tools or other projects.
Verify that the active python binary points inside your virtual environment:
2. Installing Django and Freezing Dependencies
A clean requirements.txt enables deterministic dependency reproduction across teammates and staging/production Docker containers.
3. Creating the Project and Running the Local Dev Server
In Django terminology, a Project is a collection of configurations and applications for a given website.
Navigate to http://127.0.0.1:8000/ in your browser. You will see Django's default rocket launch greeting page confirming a successful setup!
4. Understanding the manage.py Script
The manage.py file is a thin executable wrapper around django-admin that sets the DJANGO_SETTINGS_MODULE environment variable to point to your project's settings.py.
Common manage.py commands:
python manage.py runserver: Launches the development web server.python manage.py makemigrations: Generates new database migration files based on model changes.python manage.py migrate: Executes pending SQL migrations against the database.python manage.py createsuperuser: Creates an administrative user for/admin/.python manage.py startapp <app_name>: Scaffolds a new application module.python manage.py shell: Opens an interactive Python REPL with Django loaded.
Practice Quiz
Django Project Structure
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| None | Django Project Structure |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.