♦️

Django issues and quick fixes

Fighting with django

CSRF token invalid __URL__ not in trusted origin

This happens because there is no CSRF_TRUSTED_ORIGINS in the settings file. Also make sure that the url does not have an end slash


log all sql queries

simply add in settings.py

LOGGING = {
 'version': 1,
 'disable_existing_loggers': False,
 'handlers': {
  'file': {
   'level': 'DEBUG',
   'class': 'logging.FileHandler',
   'filename': 'sql.log',
  },
 },
 'loggers': {
  'django.db.backends': {
   'handlers': ['file'],
   'level': 'DEBUG',
   'propagate': True,
  },
 },
}