Django 2.0 Window expressions tutorial

By : Shabda Raaj

Django 2.0 was released recently and among the most exciting things for me is support for Window expressions, which allows adding an OVER clause to querysets. We will use Window expressions to analyze the commits data to the Django repo.

So what is an over clause?

An over clause is of this format

SELECT depname, empno, salary,
  avg(salary)
    OVER (PARTITION BY depname)
FROM empsalary;

Compare this to a similar GROUP BY statement

SELECT depname, avg(salary)
FROM empsalary
GROUP BY depname;

The difference is a GROUP BY has as many rows as grouping elements, here number of depname ...

more info..
Topics : django

Configure Django to log exceptions in production

By : Akshar Raaj

Django default logging behaviour for unhandled exceptions is:

With DEBUG=True (Development)

  • Log the exception on console/stream.
  • Show the exception on page, i.e in http response.

With DEBUG=False (Production)

  • Do not log the exception on console/stream.
  • Do not show the exception in response.
  • Send an email to admin if email settings are configured correctly.

Usually not logging the exception on console isn't a problem since an exception email is sent to you which can help you know the source of exception. But this assumes that email settings are configured correctly else you will not receive ...

more info..
Topics : django
© Agiliq, 2009-2012