Login

Django app WSGI

Author:
ofalk
Posted:
June 9, 2009
Language:
Python
Version:
1.0
Score:
2 (after 2 ratings)

If you want to have your wsgi as general as possible (for eg. different environments) without any hardcoded paths, this example might help you...

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
1   	import os
2  	import sys
3  	
4  	os.environ['DJANGO_SETTINGS_MODULE'] = 'YOURAPP.settings'
5  	
6  	project=os.path.dirname(__file__)
7  	app=os.path.dirname(project)
8  	
9  	sys.path.append(project)
10  	sys.path.append(app)
11  	
12  	from YOURAPP import settings
13  	
14  	import django.core.handlers.wsgi
15  	application = django.core.handlers.wsgi.WSGIHandler()

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 10 months, 1 week ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 2 weeks ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
  5. Help text hyperlinks by sa2812 1 year, 6 months ago

Comments

Please login first before commenting.