Python Django

From Tmplab

(Difference between revisions)
Jump to: navigation, search
(New page: = Debugging django = passenger_wsgi.py {{{ #!/usr/bin/python import sys, os f=open("/tmp/djangodebug", "w+") f.flush() sys.stderr = f try: import sys, os sys.path.append(os.get...)
Current revision (23:12, 4 November 2010) (edit) (undo)
 
(One intermediate revision not shown.)
Line 1: Line 1:
 +
= Django on Dreamhost =
 +
 +
Add this at the beginning of your passenger_wsgi.py:
 +
 +
<PRE>
 +
sys.path.append('/home/USER/HOSTNAME/django/installed/lib/python')
 +
</PRE>
 +
= Debugging django =
= Debugging django =
Line 4: Line 12:
passenger_wsgi.py
passenger_wsgi.py
-
{{{
+
<PRE>
#!/usr/bin/python
#!/usr/bin/python
import sys, os
import sys, os
Line 24: Line 32:
f.write('------------------------------')
f.write('------------------------------')
f.close()
f.close()
-
}}}
+
</PRE>

Current revision

Django on Dreamhost

Add this at the beginning of your passenger_wsgi.py:

sys.path.append('/home/USER/HOSTNAME/django/installed/lib/python')


Debugging django

passenger_wsgi.py

#!/usr/bin/python
import sys, os
f=open("/tmp/djangodebug", "w+")
f.flush()
sys.stderr = f

try:
    import sys, os
    sys.path.append(os.getcwd())
    os.environ['DJANGO_SETTINGS_MODULE'] = "XXX"
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()
except:
    f.flush()
    print "Unexpected error:", sys.exc_info()[0]
    f.write('------------------------------')
    f.write(sys.exc_info()[0])
    f.write('------------------------------')
    f.close()
Personal tools