How to install Django using an install script

To run the commands in this article, you must log into your server via SSH with your Shell user. View the following articles for more information:

  1. Log into your server via SSH with your Shell username.
  2. Make sure you’re in your site’s application directory. This is NOT the /public directory.
  3. Run the following command in this directory. This downloads a file named django-setup.py to your directory.
    [server]$ wget https://objects-us-west-1.dream.io/kbfiles/django-setup.py
  4. Run the following command:
    [server]$ python django-setup.py

After you run the setup command, the following script leads you through rest of the process of setting up your application. The sections in BOLD are required information that you must enter:

Looks like your domain is probably example.com ... cool.
Testing domain service...  lookin' good
What would you like to name your project?
>> djangotest
An excellent name!

You'll need a database for your Django project. If you don't already
have one ready, you can create one from the DreamHost Panel at:
https://panel.dreamhost.com/index.cgi?tree=goodies.mysql

MySQL hostname: mysql.example.com
Database name: mydatabasename
MySQL username: mymysqlusername
and password: *******
Checking connection...  looks good!
Creating project framework...  creating passenger_wsgi.py...  customizing settings...  setting permissions...  copying admin media...  OK
Running manage.py syncdb...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.

Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'yourusername'):
E-mail address: user@example.com
Password:
Password (again):
Superuser created successfully.

Installing custom SQL ...
Installing indexes ...
No fixtures found.
Creating a Django superuser...
Username: yourusername
E-mail address: user@example.com
Password:
Password (again):
Superuser created successfully.

SUCCESS! Your Django application is fully set up - enjoy!

Once complete, a new folder is created within your app directory which has the same name as the one you used to name your project during installation. A passenger_wsgi.py file is also created with the following:

import sys, os
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = "mydjangoprojectname.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

If you receive an error related to line 126 in the Python code, you can fix the script by appending ".py" to the OS call by changing line 126 to look like the following:

if os.spawnl(os.P_WAIT, "/usr/bin/django-admin.py", "django-admin.py", "startproject", projname) != 0:

Visit your site and you'll see a Django welcome page.

See also

Did this article answer your questions?

Article last updated .