Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It includes everything you need out of the box.
Key Concepts to Learn
- The MVT Pattern: Model, View, Template (Django's version of MVC).
- ORM (Object-Relational Mapper): Interacting with the database using Python classes instead of SQL.
- Migrations: Managing changes to your database schema.
- Admin Interface: A built-in, automatic admin site for managing data.
- Authentication: Built-in user login, logout, and permissions.
Lesson Plan
- Project vs App: Understanding Django's modular structure.
- Models: Defining data structures in
models.py. - The Admin: Registering models to see them in the admin dashboard.
- Views & URLs: Connecting logic to endpoints.
- Templates: Using Django's powerful template engine.
Running the Example
cd curriculum/djangopip install -r requirements.txtpython manage.py migrate(Create the database)python manage.py createsuperuser(Follow prompts to create an admin account)python manage.py runserver- Open
http://127.0.0.1:8000for the site, andhttp://127.0.0.1:8000/adminfor the dashboard.