Django Framework

  1. Models: The Data Layer
    1. Defining Models
      1. The `models.Model` Class
        1. Creating a Model Class
          1. Model Class Naming Conventions
            1. Model Docstrings and Meta Information
          2. Fields
            1. Common Field Types
              1. `CharField`
                1. `TextField`
                  1. `IntegerField`
                    1. `FloatField`
                      1. `BooleanField`
                        1. `DateField`
                          1. `DateTimeField`
                            1. `EmailField`
                              1. `FileField`
                                1. `ImageField`
                                  1. `URLField`
                                    1. `SlugField`
                                      1. `DecimalField`
                                        1. `PositiveIntegerField`
                                          1. `BigIntegerField`
                                            1. `TimeField`
                                              1. `DurationField`
                                                1. `UUIDField`
                                                  1. `JSONField`
                                                  2. Field Options
                                                    1. `null`
                                                      1. `blank`
                                                        1. `default`
                                                          1. `unique`
                                                            1. `primary_key`
                                                              1. `verbose_name`
                                                                1. `choices`
                                                                  1. `help_text`
                                                                    1. `editable`
                                                                      1. `max_length`
                                                                        1. `max_digits`
                                                                          1. `decimal_places`
                                                                            1. `upload_to`
                                                                              1. `db_index`
                                                                                1. `db_column`
                                                                              2. Relationships
                                                                                1. Foreign Keys (`ForeignKey`)
                                                                                  1. Defining Foreign Keys
                                                                                    1. On Delete Behaviors
                                                                                      1. `CASCADE`
                                                                                        1. `PROTECT`
                                                                                          1. `SET_NULL`
                                                                                            1. `SET_DEFAULT`
                                                                                              1. `SET()`
                                                                                                1. `DO_NOTHING`
                                                                                              2. Many-to-Many Relationships (`ManyToManyField`)
                                                                                                1. Defining Many-to-Many Fields
                                                                                                  1. Through Models
                                                                                                    1. Symmetrical Relationships
                                                                                                    2. One-to-One Relationships (`OneToOneField`)
                                                                                                      1. Use Cases for One-to-One
                                                                                                        1. Defining One-to-One Fields
                                                                                                      2. Migrations
                                                                                                        1. Creating Migrations with `makemigrations`
                                                                                                          1. Automatic Migration Detection
                                                                                                            1. Naming Migrations
                                                                                                              1. Empty Migrations
                                                                                                              2. Applying Migrations with `migrate`
                                                                                                                1. Forward Migrations
                                                                                                                  1. Fake Migrations
                                                                                                                  2. Understanding Migration Files
                                                                                                                    1. Migration File Structure
                                                                                                                      1. Dependencies and Operations
                                                                                                                        1. Migration Operations
                                                                                                                          1. `CreateModel`
                                                                                                                            1. `DeleteModel`
                                                                                                                              1. `AddField`
                                                                                                                                1. `RemoveField`
                                                                                                                                  1. `AlterField`
                                                                                                                                    1. `RenameField`
                                                                                                                                      1. `RunSQL`
                                                                                                                                        1. `RunPython`
                                                                                                                                      2. Inspecting SQL with `sqlmigrate`
                                                                                                                                        1. Rolling Back Migrations
                                                                                                                                          1. Unapplying Migrations
                                                                                                                                            1. Migration History
                                                                                                                                            2. Managing Migration Conflicts
                                                                                                                                              1. Merge Migrations
                                                                                                                                                1. Squashing Migrations
                                                                                                                                                2. Data Migrations
                                                                                                                                                  1. Creating Data Migrations
                                                                                                                                                    1. Writing Migration Functions
                                                                                                                                                  2. The Django ORM (Object-Relational Mapper)
                                                                                                                                                    1. QuerySets
                                                                                                                                                      1. Definition and Characteristics
                                                                                                                                                        1. Lazy Evaluation
                                                                                                                                                          1. QuerySet Caching
                                                                                                                                                            1. Evaluating QuerySets
                                                                                                                                                            2. Creating Objects
                                                                                                                                                              1. Using `create()`
                                                                                                                                                                1. Using `save()`
                                                                                                                                                                  1. Using `get_or_create()`
                                                                                                                                                                    1. Using `update_or_create()`
                                                                                                                                                                      1. Bulk Creation with `bulk_create()`
                                                                                                                                                                      2. Retrieving Objects
                                                                                                                                                                        1. Using `all()`
                                                                                                                                                                          1. Using `get()`
                                                                                                                                                                            1. Using `filter()`
                                                                                                                                                                              1. Using `exclude()`
                                                                                                                                                                                1. Using `first()` and `last()`
                                                                                                                                                                                  1. Using `order_by()`
                                                                                                                                                                                    1. Using `distinct()`
                                                                                                                                                                                      1. Using `values()` and `values_list()`
                                                                                                                                                                                        1. Using `only()` and `defer()`
                                                                                                                                                                                        2. Updating Objects
                                                                                                                                                                                          1. Modifying Fields and Saving
                                                                                                                                                                                            1. Using `update()`
                                                                                                                                                                                              1. Bulk Updates with `bulk_update()`
                                                                                                                                                                                              2. Deleting Objects
                                                                                                                                                                                                1. Using `delete()`
                                                                                                                                                                                                  1. Cascading Deletes
                                                                                                                                                                                                    1. Soft Deletes
                                                                                                                                                                                                  2. Advanced Querying
                                                                                                                                                                                                    1. Field Lookups
                                                                                                                                                                                                      1. `exact`
                                                                                                                                                                                                        1. `iexact`
                                                                                                                                                                                                          1. `contains`
                                                                                                                                                                                                            1. `icontains`
                                                                                                                                                                                                              1. `startswith`
                                                                                                                                                                                                                1. `endswith`
                                                                                                                                                                                                                  1. `in`
                                                                                                                                                                                                                    1. `gt`
                                                                                                                                                                                                                      1. `gte`
                                                                                                                                                                                                                        1. `lt`
                                                                                                                                                                                                                          1. `lte`
                                                                                                                                                                                                                            1. `range`
                                                                                                                                                                                                                              1. `isnull`
                                                                                                                                                                                                                                1. `regex`
                                                                                                                                                                                                                                  1. `iregex`
                                                                                                                                                                                                                                  2. Chaining Filters
                                                                                                                                                                                                                                    1. Q Objects for Complex Lookups
                                                                                                                                                                                                                                      1. Combining Queries with Q
                                                                                                                                                                                                                                        1. Negating Queries
                                                                                                                                                                                                                                          1. OR and AND Operations
                                                                                                                                                                                                                                          2. F Expressions for Field References
                                                                                                                                                                                                                                            1. Field-to-Field Comparisons
                                                                                                                                                                                                                                              1. Avoiding Race Conditions
                                                                                                                                                                                                                                                1. Mathematical Operations
                                                                                                                                                                                                                                                2. Aggregation
                                                                                                                                                                                                                                                  1. Using `Count`
                                                                                                                                                                                                                                                    1. Using `Sum`
                                                                                                                                                                                                                                                      1. Using `Avg`
                                                                                                                                                                                                                                                        1. Using `Min` and `Max`
                                                                                                                                                                                                                                                          1. Using `StdDev` and `Variance`
                                                                                                                                                                                                                                                          2. Annotation
                                                                                                                                                                                                                                                            1. Adding Calculated Fields to QuerySets
                                                                                                                                                                                                                                                              1. Conditional Annotations with `Case` and `When`
                                                                                                                                                                                                                                                              2. Subqueries
                                                                                                                                                                                                                                                                1. Using `Subquery`
                                                                                                                                                                                                                                                                  1. Using `OuterRef`
                                                                                                                                                                                                                                                                    1. Using `Exists`
                                                                                                                                                                                                                                                                    2. Raw SQL Queries
                                                                                                                                                                                                                                                                      1. Using `raw()`
                                                                                                                                                                                                                                                                        1. Using `extra()`
                                                                                                                                                                                                                                                                          1. Direct Database Connections
                                                                                                                                                                                                                                                                        2. Model Managers
                                                                                                                                                                                                                                                                          1. Default Manager
                                                                                                                                                                                                                                                                            1. Overriding the Default Manager
                                                                                                                                                                                                                                                                              1. Creating Custom Manager Methods
                                                                                                                                                                                                                                                                                1. Using Managers in Queries
                                                                                                                                                                                                                                                                                  1. Manager Inheritance
                                                                                                                                                                                                                                                                                  2. Model Methods
                                                                                                                                                                                                                                                                                    1. Instance Methods
                                                                                                                                                                                                                                                                                      1. Class Methods
                                                                                                                                                                                                                                                                                        1. Static Methods
                                                                                                                                                                                                                                                                                          1. The `str()` Method
                                                                                                                                                                                                                                                                                            1. The `get_absolute_url()` Method
                                                                                                                                                                                                                                                                                              1. Custom Save and Delete Methods
                                                                                                                                                                                                                                                                                              2. Model Meta Options
                                                                                                                                                                                                                                                                                                1. `ordering`
                                                                                                                                                                                                                                                                                                  1. `verbose_name`
                                                                                                                                                                                                                                                                                                    1. `verbose_name_plural`
                                                                                                                                                                                                                                                                                                      1. `db_table`
                                                                                                                                                                                                                                                                                                        1. `unique_together`
                                                                                                                                                                                                                                                                                                          1. `index_together`
                                                                                                                                                                                                                                                                                                            1. `permissions`
                                                                                                                                                                                                                                                                                                              1. `abstract`
                                                                                                                                                                                                                                                                                                                1. `proxy`
                                                                                                                                                                                                                                                                                                                  1. `managed`
                                                                                                                                                                                                                                                                                                                    1. `default_permissions`
                                                                                                                                                                                                                                                                                                                      1. `get_latest_by`
                                                                                                                                                                                                                                                                                                                        1. `indexes`
                                                                                                                                                                                                                                                                                                                          1. `constraints`