I would like to deplay a django application/project, which i have created within Aptana. It is a simple hello world. I can run the application locally and everything works fine, but how to deploy it to a webserver. The deploy button is grey and not working in the PyDev Perspective.
If i switch to perspective "Web Perspective" i can download(check out from a specific path with password) django applications from a webserver, edit files, and upload again. I would like to use the functionality from the web perspective in my pydev perspective where i write my django code.
But when i create my own django project, the button deploy is grey.
This is now my solution to deploy django 1.3 with aptana to Apache Server:
http://i.imgur.com/FH0E2.jpg
- Start Aptana, select PyDev Perspective (right corner) and just create a simple Django Project
- Create a views.py ane a method index()
def index(request):
return HttpResponse("Hello world")
- Edit your urls.py so that django can find the method index()
- Run Sync DB (rightclick your project in PyDev Package Explorer, at bottom click Django, and click Sync DB). I am using here a local sqlite3 db
- if everything work,s you will see within Aptana Console: Finished "/home/xy/workspace/test1/test1/manage.py syncdb" execution.
- Now Run local your django app: rightclick your project on left side of aptana (PyDev Package Explorer) somewhere in the middle you can see RUN AS: 1 PyDev:Django
- Now open your browser:
http://127.0.0.1:8000/index
or http://127.0.0.1:8000
- U see now your "Hello World"
If this worked, now lets deploy to apache:
- switch to Web Perspective (right corner of Aptana)
- switch to App Explorer (left side of Aptana) IMPORTANT!!!!!
- there is a little dropdown menu: select there your application (e.g. test1), BUT do not select any of the packages or modules inside of your project!!
- you will see now your app and nothing is selected/clicked=> you see also a little box above!
- click it and Run Web Deployment Wizard!!! if anything in your package is selected, you will not see "Run Web Deployment Wizard".... (strange)
- Select SFTP Protocol; Fill out form
- Remote Path: before you can select the directory you want to have your app uploaded, you should create it on the server
- After you have selected the directory where you want to have your app deployed to server (ubuntu) you can again click on the little box and select deploy app
- Now you get a new window SYNCHRONIZE
- Your data/app have been now uploaded to server in the chosen directory
- I use wsgi so i have to edit 2 files
- the first one is a file called test1.wsgi in the wsgi directory
import os
import sys
path = "/home/username/"
if path not in sys.path:
sys.path.append(path)
path = "/home/username/somedirectory/test1/test1/"
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi application =
django.core.handlers.wsgi.WSGIHandler()
- now go as sudo -s to cd /etc/apache2/conf.d/
- create a file test1
- write
WSGIScriptAlias /rofltest /home/username/wsgi/test1.wsgi
- /rofltest means www.youraddress.org/rofltest will be the url
/home/username/wsgi/test1.wsgi means where to look for a file which will tell where to look for your django app on the server
restart apache (/etc/init.d/apache2 restart) and browse to www.youraddress.org//rofltest/index
- You see Hello World or an error because you have to adjust the paths.
- Start with settings.py and edit ROOT_URLCONF = 'test1.urls' maybe just to 'urls'
- now it works :)
Try it, if it fails, write a comment and maybe i read it and help. If this helped, upvote it.
It doesnt work for me. Even when I extra care about not selecting the project in the App Explorer, the small "publish" icon is enabled, but the dropdown beside it is empty and nothing happens when I click it.
Actually there is a known bug when the Project root is a source folder, see https://jira.appcelerator.org/browse/APSTUD-2543