Skip to content

Instantly share code, notes, and snippets.

@githubutilities
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save githubutilities/45f38f62df5dc64bcc67 to your computer and use it in GitHub Desktop.

Select an option

Save githubutilities/45f38f62df5dc64bcc67 to your computer and use it in GitHub Desktop.
Django Log

Django in apache mod_wsgi

use sys.path.append to fix the compatiability with apache mod_wsgi

import os
import sys

# append path for the compatiability of apache2 mod_wsgi
sys.path.append('/var/www/html')

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "truth.settings")

application = get_wsgi_application()

References

Django + Apache

when you update you running django code, you better restart your apache.

Django + nohup

nohup python manage.py runserver 0.0.0.0:80

Reference

Django CORS

CORS needs Access-Control-Allow-Origin: * header.

Use curl -I <your-url> to test it.

response = JsonResponse("")
response['Access-Control-Allow-Origin'] = "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment