How to create a new Django project?
To start a project with Django, it is necessary to start the BitNami Console. If you are using a Virtual Appliance or AMI, you can run the commands below directly.
You should create your new project inside Django projects folder located at:
For 2000, XP and 2003 Server:
C:\Documents and Settings\user\Bitnami DjangoStack Projects
For Vista, 7 and 2008 Server:
C:\Users\user\Bitnami DjangoStack Projects
On OS X:
Run the following command to create a new project:
$ django-admin.py startproject my_new_project
If you wish to create a new applicaction inside the created project execute the following commands as well:
$ cd my_new_project $ python manage.py startapp my_new_app
How to start a Django project?
There are two ways to start a Django project depending of if it is a development or a production environment.
For development tasks you can use the standalone server in Django executing the following command inside your project's folder:
$ python manage.py runserver ip:port
ip and port are optional parameters. 127.0.0.1:8000 will be used by default if you don't specify any of them.
The other way is strongly recommended for production environments. It requires to configure Apache with mod_wsgi module before start serving your application. BitNami Stacks and Virtual Appliances for Django include mod_wsgi installed and activated by default. So you just need to create WSGI application script file and configure Apache to load it.
First, create the WSGI application script file named 'projectName.wsgi' in 'installdir/apps/django/scripts' folder. Add the following content setting the correct the paths and project name:
import os, sys sys.path.append('/path/to/your/django/projects/folder') sys.path.append('/path/to/your/project/folder') os.environ['DJANGO_SETTINGS_MODULE'] = 'projectName.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Once created the WSGI file, create an Apache configuration file named 'projectName.conf' in 'installdir/apps/django/conf' to load it. Please, replace installdir with your installation directory (i.e. "/opt/bitnami") and pythonversion with the Python version (i.e. "python2.7" for Python version 2.7.x).
Alias /static "installdir/apps/django/lib/pythonversion/site-packages/django/contrib/admin/static" <Directory 'installdir/apps/django/lib/pythonversion/site-packages/django/contrib/'> <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory> WSGIScriptAlias /URL_mount_point "installdir/apps/django/scripts/projectName.wsgi" <Directory 'installdir/apps/django/scripts'> <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory>
Edit the file 'httpd.conf' and add the following line:
Then restart the Apache server and visit your project at http://localhost:8080/projectName
How to configure Django with Aptana or Eclipse?
BitNami Stacks are self-contained and independent of your system. If you want to configure the Aptana development tool, you can load the Stack environment before using it.
$ source installdir/scripts/setenv.sh $ /opt/Aptana_Studio_3/AptanaStudio3
You can also integrate with Eclipse:
$ source installdir/scripts/setenv.sh $ eclipse
You can find a quick guide (spanish) at http://pategon.blogspot.com.es/2012/09/bitnami-djangostack-eclipse-pydev-aptana.html
How to upgrade Django python package?
Before upgrading Django make sure the you are Django applications are compatible with the new version.
Open the BitNami Console to load the BitNami environment if you are using the Native Installer. If you are using the Virtual Machine or the Cloud Image is not necessay.
Download the latest version from https://www.djangoproject.com/download/ and uncompress it.
On Linux and Mac OS X execute from the uncompressed directory:
python setup.py install --prefix=/installdir/apps/django
On Windows execute:
python.exe setup.py install --prefix="\installdir\apps\django" --install-lib="\installdir\apps\django" --install-scripts="\installdir\apps\django\django\bin" --install-data="\installdir\apps\django"
Notice that installdir refers to the installation directory which in virtual machines and cloud images is /opt/bitnami.