User Tools

Site Tools


code:django

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
code:django [2017/07/20 13:44]
hansek
code:django [2020/01/09 10:00] (current)
hansek
Line 29: Line 29:
   * Remove the app from INSTALLED_APPS in settings.py.   * Remove the app from INSTALLED_APPS in settings.py.
   * Delete the directory.   * Delete the directory.
 +
 +
 +===== Nginx reload =====
 +<code bash>
 +sudo nginx -s reload
 +</code>
 +
 +
 +===== ORM =====
 +
 +==== Subqueries ====
 +
 +=== Count ===
 +
 +<code python>
 +# database optimization
 +subquery = Subquery(
 +    Job.objects.published().filter(school=OuterRef('pk'))
 +        .values('school').annotate(count=Count('pk'))
 +        .values('count'), output_field=IntegerField()
 +    )
 +    qs = qs.annotate(jobs_count=Coalesce(subquery, 0))
 +</code>
 +
 +
 +
  
code/django.1500551097.txt.gz ยท Last modified: 2017/07/20 13:44 by hansek