Profile PictureShabda Raaj
$19

Django ORM Cookbook

0 ratings
Add to cart

Django ORM Cookbook

$19
0 ratings

Do you need to get better at using databases from Django? You have found the book you are looking for.

Django ORM Cookbook is a book about doing things with Django ORM and Django models. Django is a “MTV” (Model-Template-View) framework – This book provides a deep dive into the M part.

They take the form of about 50 questions of the form How to do X with Django ORM/Queryset/Models.

By reading this book, you will understand how to get the most out of Django ORM, how to do DB modelling for normalization and performance. This book serves as a handy reference, as well as a training to become a better Django developer.

Table of Contents

Querying and Filtering

1. How to find the query associated with a queryset?

2. How to do OR queries in Django ORM?

3. How to do AND queries in Django ORM?

4. How to do a NOT query in Django queryset?

5. How to do union of two querysets from same or different models?

6. How to select some fields only in a queryset?

7. How to do a subquery expression in Django?

8. How to filter a queryset with criteria based on comparing their field values

9. How to filter FileField without any file?

10. How to perform join operations in django ORM?

11. How to find second largest record using Django ORM ?

12. Find rows which have duplicate field values

13. How to find distinct field values from queryset?

14. How to use Q objects for complex queries?

15. How to group records in Django ORM?

16. How to efficiently select a random object from a model?

17. How to use arbitrary database functions in querysets?

Creating, Updating and Deleting things

1. How to create multiple objects in one shot?

2. How to copy or clone an existing model object?

3. How to ensure that only one object can be created?

4. How to update denormalized fields in other models on save?

5. How to perform truncate like operation using Django ORM?

6. What signals are raised by Django during object creation or update?

7. How to convert string to datetime and store in database?

Ordering things

1. How to order a queryset in ascending or descending order?

2. How to order a queryset in case insensitive manner?

3. How to order on two fields

4. How to order on a field from a related model (with a foreign key)?

5. How to order on an annotated field?

Database Modelling

1. How to model one to one relationships?

2. How to model one to many relationships?

3. How to model many to many relationships?

4. How to include a self-referencing ForeignKey in a model

5. How to convert existing databases to Django models?

6. How to add a model for a database view?

7. How to create a generic model which can be related to any kind of entity? (Eg. a Category or a Comment?)

8. How to specify the table name for a model?

9. How to specify the column name for model field?

10. What is the difference between null=True and blank=True?

11. How to use a UUID instead of ID as primary key?

12. How to use slug field with Django for more readability?

13. How to add multiple databases to the Django application ?

Testing

1. How to assert that a function used a fixed number of queries?

2. How to speed tests by reusing database between test runs?

3. How to reload a model object from the database?

Add to cart

You will get the book in PDF and ePub format.

Copy product URL