0

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).

markwalker_
  • 12,078
  • 7
  • 62
  • 99
  • 2
    If you are using `python manage.py runserver`, the error should be displayed in its output. – Alasdair Dec 09 '16 at 11:56
  • Have you added a logger? If not, check the first example here (to be added in the settings file of your project): https://docs.djangoproject.com/en/1.10/topics/logging/#examples Then you should see the problem in the log file you set with /path/to/django/debug.log – Yom86 Dec 09 '16 at 11:59

2 Answers2

0

If the "development server" is running on your workstation using python manage.py runserver then you just have to read the process output from the console you starded it.

If it's running behind a front server (Apache, nginx or whatever), you should configure the logging (as mentionned by Yom86), and make sure your development server correctly sends mail alerts (preferably to your own email address ) for unhandled errors.

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
0

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)
Yom86
  • 196
  • 1
  • 6