Grid Guides

Explore How System On Grid Can Work For You

Grid GuideGrid Guide Topics


Django One-Click App Setup


Introduction

One of the many available One-Click Apps that we have is Django. Django is a high-level Python Web framework that encourages rapid development so you can focus on writing your app instead of needing to reinvent the wheel.

Prerequisites

  • Orbit created with Django image

  • Running Orbit

Creating Your Orbit

  1. To create your application, you must create a Photon. You can do so by selecting the Photon tab after selecting 'Create Orbit'

    Photons
  2. Once there, you will see a list of available photons that you can create. Select one and it will bring you to a detailed page

    Photon List Photon Description
  3. Scroll down to the details and you can start selecting options for your photon as well as setting up credentials.

    Photon Details
  4. Once everything is filled in, just press Create and you can move on to the next step

SSH into Orbit

  1. First we need to check some details on our orbit by first navigating to the “My Orbits” tab.

    My Orbits
  2. Once there, click on the Orbit you want to connect to and check for three things:

    • IP Address

    • Running Status

    • Source Image(Ubuntu, Debian, Centos, Fedora)

    Orbit Details
  3. Once you have confirmed that your Orbit is running and you have the other information. Open up your console.

  4. Now you can SSH into your Orbit by running.

    ssh [email protected]
    • IP Address: We got this from the detail page, in this case it is “216.200.116.60”

    • Image: We got this from the source image in the details page. It should be one of the following: ubuntu, debian, fedora, centos

    • Note: A full command for this example would be: “ssh [email protected]

Starting Django

  1. Once you are SSH'd into the server you will see the following:

    Django CMD

    All passwords are generated when an orbit is first created and stored in a .secrets file, unless the welcome screen says otherwise. To access it, run the following command:

     cat .secrets
  2. This welcome message displays what IP address that you need to open to setup Django. After we navigate to that page, you will see the following:

    Django Start
  3. You will need to run the following commands(one after another) in the console to setup your project:

    cd myproject
    . myprojectenv/bin/activate
    ./manage.py makemigrations
    ./manage.py migrate
    Django Commands
  4. Now that all database migrations are done, there is just one more step needed before we can run the server. We need to allow hosts to connect to our website. We can set that up by doing the following in the same directory as Step 2:

    cd myproject
    pwd

    Directory should be: /home/ubuntu/myproject/myproject/myproject

    vim settings.py 

    • Modify the “ALLOWED_HOSTS” section to contain either your website name or an ‘*’
    • If you use an * just know that this is allowing all hosts to connect and it is not recommended
    • Whichever you decide to use must be encapsulated in either single or double quotes
    • How to Edit: Move the blinker to the location that you want to edit. Press “i” to enter Insert Mode, write either the website or asterisk for your ALLOWED_HOSTS, surrounded in quotes. Press “ESC” followed by “:” and finally write “wq” and press “Enter”

    Django Edit
  5. Now that the file is edited, you can start your server from the directory: /home/ubuntu/myproject/myproject:

    ./manage.py runserver 0.0.0.0:8000 
    Django Start 2
  6. If everything is working fine, you can navigate to your website with the port 8000 and it should look like this:

    Django Home