Note If you already worked through the installation steps, no need to do this again – you can skip straight ahead to How the Internet works.
In this tutorial you will be building a blog. In order to do that, as you go through the tutorial you'll be instructed on how to set up some online accounts as needed for your ChromeBook. This page gathers all of the sign-up instructions in one place (which is useful for some workshop formats).
Since you're working on a ChromeBook, your installation experience is going to be a little different. With a Chromebook, you only need to create some online accounts.
Follow the steps below to create the necessary accounts.
Cloud IDE is a tool that gives you a code editor and access to a computer running on the Internet where you can install, write, and run the software. For the duration of the tutorial, cloud IDE will act as your local machine. You'll still be running commands in a terminal interface just like your classmates on OS X, Ubuntu, or Windows, but your terminal will be connected to a computer running somewhere else that cloud IDE sets up for you. Here are the instructions for cloud IDEs (PaizaCloud Cloud IDE, AWS Cloud9, Glitch.com). You can choose one of the cloud IDEs, and follow the instruction of the cloud IDE.
- Go to PaizaCloud Cloud IDE
- Sign up for an account
- Click New Server and choose the Django app
- Click Terminal button(on the left side of the window)
Now you should see an interface with a sidebar, buttons at the left. Click "Terminal" button to open terminal window with prompt like this:
{% filename %}Terminal{% endfilename %}
$
The terminal on the PaizaCloud Cloud IDE is prepared for your instructions. You can resize or maximize that window to make it a bit bigger.
Currently Cloud 9 requires you to sign up with AWS and enter credit card information.
- Install Cloud 9 from the Chrome web store
- Go to c9.io and click Get started with AWS Cloud9
- Sign up for an AWS account (requires credit card information, but you can use it for free)
- In the AWS Dashboard, enter Cloud9 in the search bar and click it
- In the Cloud 9 dashboard, click Create environment
- Name it django-girls
- While configuring settings, select Create a new instance for environment (EC2) for "Environment Type" and the t2.micro "Instance type" (it should say "Free-tier eligible."). The default cost-saving setting is fine and you can keep the other defaults.
- Click Next step
- Click Create environment
Now you should see an interface with a sidebar, a big main window with some text, and a small window at the bottom that looks something like this:
{% filename %}bash{% endfilename %}
yourusername:~/workspace $
This bottom area is your terminal. You can use the terminal to send instructions to the remote Cloud 9 computer. You can resize that window to make it a bit bigger.
- Go to Glitch.com
- Sign up for an account (https://glitch.com/signup) or use your GitHub account if you have one. (See GitHub instructions below.)
- Click New Project and choose hello-webpage
- Click on the Tools dropdown list (at the bottom left side of the window), then on Terminal button to open terminal tab with a prompt like this:
{% filename %}Terminal{% endfilename %}
app@name-of-your-glitch-project:~
When using Glitch.com as your Cloud IDE, you don't have to create a virtual environment. Instead, create the following files manually:
{% filename %}glitch.json{% endfilename %}
{
"install": "pip3 install -r requirements.txt --user",
"start": "bash start.sh",
"watch": {
"throttle": 1000
}
}
{% filename %}requirements.txt{% endfilename %}
Django~={{ book.django_version }}
{% filename %}.bash_profile{% endfilename %}
alias python=python3
alias pip=pip3
{% filename %}start.sh{% endfilename %}
chmod 600 .bash_profile
pip3 install -r requirements.txt --user
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver $PORT
Once these files are created, go to the Terminal and execute the following commands to create your first Django project:
{% filename %}Terminal{% endfilename %}
django-admin.py startproject mysite .
refresh
In order to see detailed error messages, you can activate Django debug logs for your Glitch application.
Simply add the following at the end of the mysite/settings.py
file.
{% filename %}mysite/settings.py{% endfilename %}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}
This will create a debug.log
file detailing Django operations and any error messages that might come up, making it much easier
to fix if your website does not work.
The initial restarting of the Glitch project should fail.
(If you click on the top dropdown button Show
then click on In a New Window
, you will receive a DisallowedHost
error
message.)
Do not worry about it at this stage, the tutorial will fix this as soon as you update the Django settings of your project in the
mysite/settings.py
file.
A virtual environment (also called a virtualenv) is like a private box we can stuff useful computer code into for a project we're working on. We use them to keep the various bits of code we want for our various projects separate so things don't get mixed up between projects.
Run:
{% filename %}Cloud 9{% endfilename %}
mkdir djangogirls
cd djangogirls
python3 -m venv myvenv
source myvenv/bin/activate
pip install django~={{ book.django_version }}
(note that on the last line we use a tilde followed by an equal sign: ~=
).
Make a GitHub account.
The Django Girls tutorial includes a section on what is called Deployment, which is the process of taking the code that powers your new web application and moving it to a publicly accessible computer (called a server) so other people can see your work.
This part is a little odd when doing the tutorial on a Chromebook since we're already using a computer that is on the Internet (as opposed to, say, a laptop). However, it's still useful, as we can think of our Cloud 9 workspace as a place for our "in progress" work and Python Anywhere as a place to show off our stuff as it becomes more complete.
Thus, sign up for a new Python Anywhere account at www.pythonanywhere.com.
{% include "/deploy/signup_pythonanywhere.md" %}
Congratulations, you are all set up and ready to go!If you still have some time before the workshop, it would be useful to start reading a few of the beginning chapters:
When you begin the workshop, you'll be able to go straight to Your first Django project! because you already covered the material in the earlier chapters.