@@ -32,16 +32,16 @@ Installation
32
32
33
33
1. Requirements: **Django > 3 ** and **Python > 3 **
34
34
35
- 2. ``pip install django-admin-easy==0.8.0 ``
35
+ ``pip install django-admin-easy==0.8.0 ``
36
36
37
37
38
38
* For **Django < 1.8 ** or **Python 2.x **
39
39
40
- ``pip install django-admin-easy==0.4.1 ``
40
+ ``pip install django-admin-easy==0.4.1 ``
41
41
42
42
* For **Django < 2 **
43
43
44
- ``pip install django-admin-easy==0.7 ``
44
+ ``pip install django-admin-easy==0.7.0 ``
45
45
46
46
47
47
How it Works
@@ -267,10 +267,13 @@ More Examples
267
267
# don't forget to use select_related with content-type to avoid N+1 queries like example below
268
268
generic = easy.GenericForeignKeyAdminField(' generic' )
269
269
270
- # Example if your model has a field like this:
271
- # content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
272
- def queryset (self , queryset ):
273
- return queryset.select_related(' content_type' )
270
+ def get_queryset (self , request ):
271
+ qs = super ().get_queryset(request)
272
+
273
+ return qs.select_related(' content_type' )
274
+
275
+ # or enable cache
276
+ generic = easy.GenericForeignKeyAdminField(' generic' , cache_content_type = True )
274
277
275
278
# display image of some model
276
279
image1 = easy.ImageAdminField(' image' , {' image_attrs' :' attr_value' })
0 commit comments