Django: Difference between revisions
(Created page with "== Installing your django apps on Piet Zwart 3 == Ensure that you have a folder called "django" in your home folder (ie /home/YOURUSERNAME/django/). 1. Copy your Django proj...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
Ensure that you have a folder called "django" in your home folder (ie /home/YOURUSERNAME/django/). | Ensure that you have a folder called "django" in your home folder (ie /home/YOURUSERNAME/django/). | ||
1. Copy your Django project (DJPROJECT) into that folder (ie /home/YOURUSERNAME/django/DJPROJECT/). | '''1.''' Copy your Django project (say it's called DJPROJECT) into that folder (ie /home/YOURUSERNAME/django/DJPROJECT/). | ||
2. Create a "wsgi" file and name it DJPROJECT.wsgi and put it in the django folder (ie /home/YOURUSERNAME/django/DJPROJECT.wsgi) | |||
'''2.''' Create a "wsgi" file and name it DJPROJECT.wsgi and put it in the django folder (ie /home/YOURUSERNAME/django/DJPROJECT.wsgi) | |||
Inside the file should be like: | Inside the file should be like: | ||
<source lang="python"> | <source lang="python"> | ||
import os, sys | |||
sys.path.append("/home/YOURUSERNAME/django/") | |||
sys.path.append("/home/YOURUSERNAME/django/DJPROJECT/") | |||
os.environ['DJANGO_SETTINGS_MODULE'] = 'DJPROJECT.settings' | |||
import django.core.handlers.wsgi | |||
application = django.core.handlers.wsgi.WSGIHandler() | |||
</source> | </source> | ||
Replacing YOURUSERNAME & DJPROJECTNAME with your username & the django project name! | |||
That should be it! To view the project/app, go to: | That should be it! To view the project/app, go to: | ||
http://pzwart3.wdka.hro.nl/django/YOURUSERNAME/DJPROJECT/ | http://pzwart3.wdka.hro.nl/django/YOURUSERNAME/DJPROJECT/ | ||
To run django "management" commands, you can ssh, and then cd into django/DJPROJECT, and from there you can: | |||
python manage.py shell | |||
or whatever. NB: you don't need to use runserver here because it's already setup to be served by Apache! | |||
=== To reload your code === | |||
Apache will not automatically reload your project/app when the code changes. To force this to happen you need to "touch" your wsgi file (which is like marking it as having changed, and which lets apache know that it needs to reload your code: | |||
ssh YOURUSERNAME@pzwart3.wdka.hro.nl | |||
cd django | |||
touch DJPROJECT.wsgi |
Latest revision as of 13:55, 9 April 2013
Installing your django apps on Piet Zwart 3
Ensure that you have a folder called "django" in your home folder (ie /home/YOURUSERNAME/django/).
1. Copy your Django project (say it's called DJPROJECT) into that folder (ie /home/YOURUSERNAME/django/DJPROJECT/).
2. Create a "wsgi" file and name it DJPROJECT.wsgi and put it in the django folder (ie /home/YOURUSERNAME/django/DJPROJECT.wsgi) Inside the file should be like:
import os, sys
sys.path.append("/home/YOURUSERNAME/django/")
sys.path.append("/home/YOURUSERNAME/django/DJPROJECT/")
os.environ['DJANGO_SETTINGS_MODULE'] = 'DJPROJECT.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Replacing YOURUSERNAME & DJPROJECTNAME with your username & the django project name!
That should be it! To view the project/app, go to:
http://pzwart3.wdka.hro.nl/django/YOURUSERNAME/DJPROJECT/
To run django "management" commands, you can ssh, and then cd into django/DJPROJECT, and from there you can:
python manage.py shell
or whatever. NB: you don't need to use runserver here because it's already setup to be served by Apache!
To reload your code
Apache will not automatically reload your project/app when the code changes. To force this to happen you need to "touch" your wsgi file (which is like marking it as having changed, and which lets apache know that it needs to reload your code:
ssh YOURUSERNAME@pzwart3.wdka.hro.nl cd django
touch DJPROJECT.wsgi