Skip to content

Restructure tutorial to separate instructions based on operating system #1796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: restructure-tutorial
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
564152a
Switch to actions/deploy-pages
ekohl Apr 6, 2023
39b7faa
Merge pull request #1791 from ekohl/remove-need-for-gh-pages-branch
amakarudze Apr 19, 2023
00446f4
Split setup instructions and summary
amakarudze Apr 19, 2023
ab0d913
Restructure content by OS, refactor installation steps
amakarudze Apr 21, 2023
fdbbb86
Remove unnecessary files from Chromebook folder
amakarudze Apr 21, 2023
91ee4c3
Fix Python installation and introduction sections
amakarudze Apr 21, 2023
db9e969
Fix django installation instructions
amakarudze Apr 21, 2023
efe896a
Restruture content up to Python introduction
amakarudze Apr 27, 2023
8fc2734
Refactor deploy folder, delete reduntant folders
amakarudze Apr 28, 2023
5368e73
Fix line breaks at 80 for chromebook/README.md
amakarudze Jun 1, 2023
11488b4
Fix lines for chromebook/django_start_project/README.md
amakarudze Jun 1, 2023
0c3e2d7
Fix line length for macosx/django_start_project/README.md
amakarudze Jun 1, 2023
808a0fd
Fix runcode file line length
amakarudze Jun 1, 2023
b3f114c
Fix line length for windows and runcode
amakarudze Jun 19, 2023
7bd90b9
Fix lines for code editor folder
amakarudze Jun 19, 2023
dcde212
Fix line length for more files
amakarudze Jun 19, 2023
3dd54d8
Fix link for runcode django_start_project
amakarudze Jun 19, 2023
213850f
Fix navigation issues, refactor SUMMARY.md
amakarudze Jun 29, 2023
cf28896
fix: relative image paths in specific os folders
jwhhh Oct 5, 2023
19ba762
Merge pull request #1 from jwhhh/change-structure-1792
amakarudze Nov 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix line length for windows and runcode
  • Loading branch information
amakarudze committed Jun 19, 2023
commit b3f114ccf57092e45fbaece41ab101e98d3ebe66
135 changes: 30 additions & 105 deletions en/runcode/django_start_project/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,29 @@
# Your first Django project!

> Part of this chapter is based on tutorials by Geek Girls Carrots
(https://github.com/ggcarrots/django-carrots).
> Part of this chapter is based on tutorials by Geek Girls Carrots (https://github.com/ggcarrots/django-carrots).

> Parts of this chapter are based on the [django-marcador
tutorial](http://django-marcador.keimlink.de/) licensed under the Creative Commons
Attribution-ShareAlike 4.0 International License. The django-marcador tutorial
is copyrighted by Markus Zapke-Gründemann et al.
> Parts of this chapter are based on the [django-marcador tutorial](http://django-marcador.keimlink.de/) licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. The django-marcador tutorial is copyrighted by Markus Zapke-Gründemann et al.

We're going to create a small blog!

The first step is to start a new Django project.
Basically, this means that we'll run some scripts provided by Django that will
create the skeleton of a Django project for us. This is just a bunch of
directories and files that we will use later.
The first step is to start a new Django project. Basically, this means that we'll run some scripts provided by Django that will create the skeleton of a Django project for us. This is just a bunch of directories and files that we will use later.

The names of some files and directories are very important for Django.
You should not rename the files that we are about to create.
Moving them to a different place is also not a good idea.
Django needs to maintain a certain structure to be able to find important things.
The names of some files and directories are very important for Django. You should not rename the files that we are about to create. Moving them to a different place is also not a good idea. Django needs to maintain a certain structure to be able to find important things.

> Remember to run everything in the virtualenv.
If you don't see a prefix `(myvenv)` in your console, you need to activate your
virtualenv.
We explained how to do that in the __Django installation__ chapter in the
__Working with virtualenv__ part.
Typing `source myvenv/bin/activate` will do this for you.
> Remember to run everything in the virtualenv. If you don't see a prefix `(myvenv)` in your console, you need to activate your virtualenv. We explained how to do that in the __Django installation__ chapter in the __Working with virtualenv__ part. Typing `source myvenv/bin/activate` will do this for you.

In your Linux console, you should run the following command.
**Don't forget to add the period (or dot) `.` at the end!**
In your Linux console, you should run the following command. **Don't forget to add the period (or dot) `.` at the end!**

{% filename %}command-line{% endfilename %}
```
(myvenv) ~/djangogirls$ django-admin startproject mysite .
```

> The period `.` is crucial because it tells the script to install Django in
your current directory (for which the period `.` is a short-hand reference).
> The period `.` is crucial because it tells the script to install Django in your current directory (for which the period `.` is a short-hand reference).

> **Note** When typing the command above, remember that you only type the part
which starts by `django-admin`.
The `(myvenv) ~/djangogirls$` part shown here is just example of the prompt
that will be inviting your input on your command line.
> **Note** When typing the command above, remember that you only type the part which starts by `django-admin`. The `(myvenv) ~/djangogirls$` part shown here is just example of the prompt that will be inviting your input on your command line.

`django-admin.py` is a script that will create the directories and files for you.
You should now have a directory structure which looks like this:
`django-admin.py` is a script that will create the directories and files for you. You should now have a directory structure which looks like this:

```
djangogirls
Expand All @@ -59,80 +38,50 @@ djangogirls
│   └── ...
└── requirements.txt
```
> **Note**: in your directory structure, you will also see your `myvenv`
directory that we created before.
> **Note**: in your directory structure, you will also see your `myvenv` directory that we created before.

`manage.py` is a script that helps with management of the site.
With it we will be able (amongst other things) to start a web server on our
computer without installing anything else.
`manage.py` is a script that helps with management of the site. With it we will be able (amongst other things) to start a web server on our computer without installing anything else.

The `settings.py` file contains the configuration of your website.

Remember when we talked about a mail carrier checking where to deliver a letter?
`urls.py` file contains a list of patterns used by `urlresolver`.
Remember when we talked about a mail carrier checking where to deliver a letter? `urls.py` file contains a list of patterns used by `urlresolver`.

Let's ignore the other files for now as we won't change them.
The only thing to remember is not to delete them by accident!
Let's ignore the other files for now as we won't change them. The only thing to remember is not to delete them by accident!


## Changing settings

Let's make some changes in `mysite/settings.py`.
Open the file using the code editor you installed earlier.
Let's make some changes in `mysite/settings.py`. Open the file using the code editor you installed earlier.

**Note**: Keep in mind that `settings.py` is a regular file, like any other.
You can open it from inside the code editor, using the "file -> open" menu actions.
This should get you the usual window in which you can navigate to your
`settings.py` file and select it.
Alternatively, you can open the file by navigating to the djangogirls folder on
your desktop and right-clicking on it. Then, select your code editor from the list.
Selecting the editor is important as you might have other programs installed
that can open the file but will not let you edit it.
**Note**: Keep in mind that `settings.py` is a regular file, like any other. You can open it from inside the code editor, using the "file -> open" menu actions. This should get you the usual window in which you can navigate to your `settings.py` file and select it. Alternatively, you can open the file by navigating to the djangogirls folder on your desktop and right-clicking on it. Then, select your code editor from the list. Selecting the editor is important as you might have other programs installed that can open the file but will not let you edit it.

It would be nice to have the correct time on our website.
Go to [Wikipedia's list of time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
and copy your relevant time zone (TZ) (e.g. `Europe/Berlin`).
It would be nice to have the correct time on our website. Go to [Wikipedia's list of time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) and copy your relevant time zone (TZ) (e.g. `Europe/Berlin`).

In `settings.py`, find the line that contains `TIME_ZONE` and modify it to
choose your own timezone.
For example:
In `settings.py`, find the line that contains `TIME_ZONE` and modify it to choose your own timezone. For example:

{% filename %}mysite/settings.py{% endfilename %}
```python
TIME_ZONE = 'Europe/Berlin'
```

A language code consist of the language, e.g. `en` for English or `de` for German,
and the country code, e.g. `de` for Germany or `ch` for Switzerland.
If English is not your native language, you can add this to change the default
buttons and notifications from Django to be in your language.
So you would have "Cancel" button translated into the language you defined here.
[Django comes with a lot of prepared translations](https://docs.djangoproject.com/en/3.2/ref/settings/#language-code).
A language code consist of the language, e.g. `en` for English or `de` for German, and the country code, e.g. `de` for Germany or `ch` for Switzerland. If English is not your native language, you can add this to change the default buttons and notifications from Django to be in your language. So you would have "Cancel" button translated into the language you defined here. [Django comes with a lot of prepared translations](https://docs.djangoproject.com/en/3.2/ref/settings/#language-code).

If you want a different language, change the language code by changing the
following line:
If you want a different language, change the language code by changing the following line:

{% filename %}mysite/settings.py{% endfilename %}
```python
LANGUAGE_CODE = 'de-ch'
```


We'll also need to add a path for static files.
(We'll find out all about static files and CSS later in the tutorial.)
Go down to the *end* of the file, and just underneath the `STATIC_URL` entry,
add a new one called `STATIC_ROOT`:
We'll also need to add a path for static files. (We'll find out all about static files and CSS later in the tutorial.) Go down to the *end* of the file, and just underneath the `STATIC_URL` entry, add a new one called `STATIC_ROOT`:

{% filename %}mysite/settings.py{% endfilename %}
```python
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
```

When `DEBUG` is `True` and `ALLOWED_HOSTS` is empty, the host is validated
against `['localhost', '127.0.0.1', '[::1]']`.
This won't match our hostname on RunCode and on PythonAnywhere once we deploy our application
so we will change the following setting:
When `DEBUG` is `True` and `ALLOWED_HOSTS` is empty, the host is validated against `['localhost', '127.0.0.1', '[::1]']`. This won't match our hostname on RunCode and on PythonAnywhere once we deploy our application so we will change the following setting:

{% filename %}mysite/settings.py{% endfilename %}
```python
Expand All @@ -141,8 +90,7 @@ ALLOWED_HOSTS = ['127.0.0.1', '.runcode.io', '.pythonanywhere.com']

## Set up a database

There's a lot of different database software that can store data for your site.
We'll use the default one, `sqlite3`.
There's a lot of different database software that can store data for your site. We'll use the default one, `sqlite3`.

This is already set up in this part of your `mysite/settings.py` file:

Expand All @@ -156,10 +104,7 @@ DATABASES = {
}
```

To create a database for our blog, let's run the following in the console:
`python manage.py migrate` (we need to be in the `djangogirls` directory that
contains the `manage.py` file).
If that goes well, you should see something like this:
To create a database for our blog, let's run the following in the console: `python manage.py migrate` (we need to be in the `djangogirls` directory that contains the `manage.py` file). If that goes well, you should see something like this:

{% filename %}command-line{% endfilename %}
```
Expand Down Expand Up @@ -191,53 +136,33 @@ And we're done! Time to start the web server and see if our website is working!

## Starting the web server

You need to be in the directory that contains the `manage.py` file
(the `djangogirls` directory).
In the console, we can start the web server by running `python manage.py runserver`:
You need to be in the directory that contains the `manage.py` file (the `djangogirls` directory). In the console, we can start the web server by running `python manage.py runserver`:

{% filename %}command-line{% endfilename %}
```
(myvenv) ~/djangogirls$ python manage.py runserver
```

Now you need to check that your website is running.
On RunCode cloud platform, the URL will look something like this:
`https://8000-soft-limit-18855079.eu-ws4.runcode.io/`.
Open another tab/window in your browser (Firefox, Chrome, Safari, Internet
Explorer or whatever you
use) and enter the address to your instance.
Now you need to check that your website is running. On RunCode cloud platform, the URL will look something like this: `https://8000-soft-limit-18855079.eu-ws4.runcode.io/`. Open another tab/window in your browser (Firefox, Chrome, Safari, Internet Explorer or whatever you use) and enter the address to your instance.

The URL to your own instance, will be like:

{% filename %}browser{% endfilename %}
```
https://8000-the-name-of-your-runcode-instance.eu-ws4.runcode.io/
```
You can open this in another browser window and you should see the Django
nstall worked page.
You can open this in another browser window and you should see the Django 'Installation done' page.

Congratulations! You've just created your first website and run it using a web
server! Isn't that awesome?
Congratulations! You've just created your first website and run it using a web server! Isn't that awesome?

Congratulations!
You've just created your first website and run it using a web server!
Isn't that awesome?
Congratulations! You've just created your first website and run it using a web server! Isn't that awesome?

![Install worked!](/images/install_worked.png)

Note that a command window can only run one thing at a time, and the command
window you opened earlier is running the web server.
As long as the web server is running and waiting for additional incoming
requests, the terminal will accept new text but will not execute new commands.
Note that a command window can only run one thing at a time, and the command window you opened earlier is running the web server. As long as the web server is running and waiting for additional incoming requests, the terminal will accept new text but will not execute new commands.

> We reviewed how web servers work in the <b>How the Internet works</b> chapter.

To type additional commands while the web server is running, open a new
terminal window and activate your virtualenv -- to review instructions on how to
open a second terminal window, see
[Introduction to the command line](../intro_to_command_line/README.md).
To stop the web server, switch back to the window in which it's running and
press CTRL+C - Control and C keys together (on Windows, you might have to
press Ctrl+Break).
To type additional commands while the web server is running, open a new terminal window and activate your virtualenv -- to review instructions on how to open a second terminal window, see [Introduction to the command line](../intro_to_command_line/README.md). To stop the web server, switch back to the window in which it's running and press CTRL+C - Control and C keys together (on Windows, you might have to press Ctrl+Break).

Ready for the next step? It's time to create some content!
36 changes: 8 additions & 28 deletions en/windows/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
# Windows Installation

> **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](../how_the_internet_works/README.md).
> **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](../how_the_internet_works/README.md).

# Installation
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 install various software on your computer and set up some online accounts as needed.
This page gathers all of the installation and sign-up instructions in one place
(which is useful for some workshop formats).

Since you're working on Windows, your experience will be a little different.
When you get to the deployment chapter, you will experience Linux environment
and you can always refer to the
[Linux command line instructions](linux/intro_to_command_line/README.md) if you
need to learn more on Linux command line.
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 install various software on your computer and set up some online accounts as needed. This page gathers all of the installation and sign-up instructions in one place (which is useful for some workshop formats).

Since you're working on Windows, your experience will be a little different. When you get to the deployment chapter, you will experience Linux environment and you can always refer to the [Linux command line instructions](linux/intro_to_command_line/README.md) if you need to learn more on Linux command line.

To install software on your machine, follow the instructions below:

## Brief intro to the command line {#intro-command-line}
Many of the steps below reference the "console", "terminal", "command window",
or "command line" -- these all mean the same thing: a window on your computer
where you can enter commands.
When you get to the main tutorial, you'll learn more about the command line.
For now, the main thing you need to know is how to open a command window and
what it looks like:
Many of the steps below reference the "console", "terminal", "command window", or "command line" -- these all mean the same thing: a window on your computer where you can enter commands. When you get to the main tutorial, you'll learn more about the command line. For now, the main thing you need to know is how to open a command window and what it looks like:

{% include "intro_to_command_line/open_instructions.md" %}

Expand All @@ -42,17 +27,14 @@ what it looks like:
{% include "deploy/install_git.md" %}

## Create a GitHub account {#github-account}
Go to [GitHub.com](https://www.github.com) and sign up for a new, free user account.
Be sure to remember your password (add it to your password manager, if you use one).
Go to [GitHub.com](https://www.github.com) and sign up for a new, free user account. Be sure to remember your password (add it to your password manager, if you use one).

## Create a PythonAnywhere account {#pythonanywhere-account}
{% include "/deploy/signup_pythonanywhere.md" %}

# Start reading

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:
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:

* [How the internet works](../how_the_internet_works/README.md)

Expand All @@ -64,6 +46,4 @@ beginning chapters:

# Enjoy the workshop!

When you begin the workshop, you'll be able to go straight to
[Your first Django project!](../windows/django_start_project/README.md) because you
already covered the material in the earlier chapters.
When you begin the workshop, you'll be able to go straight to [Your first Django project!](../windows/django_start_project/README.md) because you already covered the material in the earlier chapters.
Loading