Search code examples
djangohttp-status-code-500

Making call to django web server causes Error 500


I am having an iPad application that does calls to a django server to get data. On the production server calls work just fine, but when I move app to make calls to development server I get an 500 server error (since iPad app works while making calls to production server, I suspect that the problem is on the development server).

Since I'm very new in this technology(Django) I don't know what code/logs should I provide or what should I do. Any clue on how can I debug that would be welcomed(also, I can provide anything that might help).


Solution

  • Have you added a logger?

    If not, the doc is here: https://docs.djangoproject.com/en/1.10/topics/logging/#examples

    And here is an example that you can copy paste in the settings of your project. The logs will go in logs/django.log:

    LOGGING_CONFIG = None
    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'verbose': {
                'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
                'datefmt' : "%d/%b/%Y %H:%M:%S"
            },
            'simple': {
                'format': '[%(asctime)s] %(levelname)s %(message)s',
                'datefmt' : "%d/%b/%Y %H:%M:%S"
            },
        },
        'handlers': {
            'djangofile': {
                'level': 'DEBUG',
                'class': 'logging.handlers.TimedRotatingFileHandler',
                'filename': 'logs/django.log',
                'when':'midnight',
                'backupCount':7,
                'formatter': 'verbose'
            },
        },
        'loggers': {
            'django': {
                'handlers':['djangofile'],
                'propagate': True,
                'level':'DEBUG',
            },
        }
    }
    import logging.config
    logging.config.dictConfig(LOGGING)