Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions en/code_editor/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Atom is an extremely new code editor created by [GitHub](http://github.com/). It

You might be wondering why we are installing this special code editor software, rather than using something like Word or Notepad.

The first is that code needs to be **plain text**, and the problem with programs like Word and Textedit is that they don't actually produce plain text, they produce rich text (with fonts and formatting), using custom formats like rtf.
The first is that code needs to be **plain text**, and the problem with programs like Word and Textedit is that they don't actually produce plain text, they produce rich text (with fonts and formatting), using custom formats like [RTF (Rich Text Format)](https://en.wikipedia.org/wiki/Rich_Text_Format).

The second reason is that code editors are specialised in editing code, so they can provide helpful features, like highlighting code with colour according to its meaning, or automatically closing quotes for you.
The second reason is that code editors are specialised for editing code, so they can provide helpful features like highlighting code with colour according to its meaning, or automatically closing quotes for you.

We'll see all this in action later. Soon, you'll come to think of your trusty old code editor as one of your favourite tools :)

4 changes: 2 additions & 2 deletions en/django/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# What is Django?

Django (_/ˈdʒæŋɡoʊ/ jang-goh_) is a free and open source web application framework, written in Python. It's a web framework - a set of components that helps you to develop websites faster and easier.
Django (_/ˈdʒæŋɡoʊ/ jang-goh_) is a free and open source web application framework, written in Python. A web framework is a set of components that helps you to develop websites faster and easier.

You see, when you're building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
When you're building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.

Luckily for you other people long ago noticed that web developers face similar problems when building a new site, so they teamed up and created frameworks (Django is one of them) that give you ready-made components you can use.

Expand Down
23 changes: 12 additions & 11 deletions en/django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ There is a concept in programming called `Object-oriented programming`. The idea

So what is an object? It is a collection of properties and actions. It sounds weird, but we will give you an example.

If we want to model a cat we will create an object `Cat` that has some properties, i.e. `color`, `age`, `mood` (i.e. good, bad, sleepy ;)), `owner` (that is a `Person` object or maybe, in case of a stray cat, this property is empty).
If we want to model a cat we will create an object `Cat` that has some properties such as: `color`, `age`, `mood` (i.e. good, bad, sleepy ;)), and `owner` (that is a `Person` object or maybe, in case of a stray cat, this property is empty).

And then the `Cat` has some actions: `purr`, `scratch` or `feed` (in which we will give the cat some `CatFood`, which could be a separate object with properties, i.e. `taste`).
Then the `Cat` has some actions: `purr`, `scratch`, or `feed` (in which we will give the cat some `CatFood`, which could be a separate object with properties, i.e. `taste`).

Cat
--------
Expand Down Expand Up @@ -45,7 +45,7 @@ Well, for sure our blog post needs some text with its content and a title, right

What kind of things could be done with a blog post? It would be nice to have some `method` that publishes the post, right?

So we will need `publish` method.
So we will need a `publish` method.

Since we already know what we want to achieve, we can start modeling it in Django!

Expand Down Expand Up @@ -131,39 +131,40 @@ All lines starting with `from` or `import` are lines that add some bits from oth
`class Post(models.Model):` - this line defines our model (it is an `object`).

- `class` is a special keyword that indicates that we are defining an object.
- `Post` is the name of our model, we can give it a different name (but we must avoid special characters and whitespaces). Always start a class name with an uppercase letter.
- `Post` is the name of our model. We can give it a different name (but we must avoid special characters and whitespaces). Always start a class name with an uppercase letter.
- `models.Model` means that the Post is a Django Model, so Django knows that it should be saved in the database.

Now we define properties we were talking about: `title`, `text`, `created_date`, `published_date` and `author`. To do that we need to define a type of field (is it text? A number? A date? A relation to another object, i.e. a User?).
Now we define the properties we were talking about: `title`, `text`, `created_date`, `published_date` and `author`. To do that we need to define a type of each field (Is it text? A number? A date? A relation to another object, i.e. a User?).

- `models.CharField` - this is how you define text with a limited number of characters.
- `models.TextField` - this is for long texts without a limit. It will be ideal for a blog post content, right?
- `models.TextField` - this is for long text without a limit. Sounds ideal for blog post content, right?
- `models.DateTimeField` - this is a date and time.
- `models.ForeignKey` - this is a link to another model.

We will not explain every bit of code here, since it would take too much time. You should take a look at Django's documentation, if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/1.8/ref/models/fields/#field-types).
We will not explain every bit of code here, since it would take too much time. You should take a look at Django's documentation if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/1.8/ref/models/fields/#field-types).

What about `def publish(self):`? It is exactly our `publish` method we were talking about before. `def` means that this is a function/method. `publish` is the name of the method. You can change it, if you want. The rule is that we use lowercase and underscores instead of whitespaces (i.e. if you want to have a method that calculates average price you could call it `calculate_average_price`).
What about `def publish(self):`? It is exactly our `publish` method we were talking about before. `def` means that this is a function/method and `publish` is the name of the method. You can change the name of the method, if you want. The naming rule is that we use lowercase and underscores instead of whitespaces (i.e. if you want to have a method that calculates average price you could call it `calculate_average_price`).

Methods very often `return` something. There is an example of that in the `__str__` method. In this scenario, when we call `__str__()` we will get a text (**string**) with a Post title.

If something is still not clear about models, feel free to ask your coach! We know it is very complicated, especially when you learn what objects and functions are at the same time. But hopefully it looks slightly less magic for you now!

### Create tables for models in your database

The last step here is to add our new model to our database. First we have to make Django know that we have some changes in our model (we have just created it), type `python manage.py makemigrations blog`. It will look like this:
The last step here is to add our new model to our database. First we have to make Django know that we have some changes in our model (we have just created it!). Type `python manage.py makemigrations blog`. It will look like this:

(myvenv) ~/djangogirls$ python manage.py makemigrations blog
Migrations for 'blog':
0001_initial.py:
- Create model Post

Django prepared for us a migration file that we have to apply now to our database, type `python manage.py migrate blog`, the output should be:
Django prepared for us a migration file that we have to apply now to our database. Type `python manage.py migrate blog` and the output should be:

(myvenv) ~/djangogirls$ python manage.py migrate blog
Operations to perform:
Apply all migrations: blog
Running migrations:
Rendering model states... DONE
Applying blog.0001_initial... OK

Hurray! Our Post model is now in our database, it would be nice to see it, right? Jump to the next chapter to see what your Post looks like!
Hurray! Our Post model is now in our database! It would be nice to see it, right? Jump to the next chapter to see what your Post looks like!
22 changes: 17 additions & 5 deletions en/django_start_project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ is copyrighted by Markus Zapke-Gründemann et al.

We're going to create a simple blog!

The first step towards creating it 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: a bunch of directories and files that we will later use.
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: a bunch of directories and files that we will later use.

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 in order 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. You can do that by typing the following command: `myvenv\Scripts\activate` on Windows or
> 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. You can do that by typing the following command: `myvenv\Scripts\activate` on Windows or
`myvenv/bin/activate` on Mac OS / Linux.

In your MacOS or Linux console you should run the following command; **don't forget to add the period (or dot) `.` at the end**:
Expand All @@ -26,7 +26,7 @@ On Windows; **don't forget to add the period (or dot) `.` at the end**:

> 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 commands above, remember that you only type the part which starts `django-admin` or `django-admin.py`.
> **Note** When typing the commands above, remember that you only type the part which starts `django-admin` or `django-admin.py`.
The`(myvenv) ~/djangogirls$` and `(myvenv) C:\Users\Name\djangogirls>` parts shown here are just examples
of the prompt that will be inviting your input on your command line.

Expand Down Expand Up @@ -69,7 +69,7 @@ We'll also need to add a path for static files (we'll find out all about static

```python
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
```


Expand All @@ -92,11 +92,23 @@ To create a database for our blog, let's run the following in the console: `pyth

(myvenv) ~/djangogirls$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, auth, sessions
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: contenttypes, sessions, admin, auth
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying sessions.0001_initial... OK

And we're done! Time to start the web server and see if our website is working!
Expand Down
2 changes: 1 addition & 1 deletion en/intro_to_command_line/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Windows:

> mkdir djangogirls

This little command will create a folder with the name `djangogirls` on your desktop. You can check if it's there just by looking on your Desktop or by running a `ls`/`dir` command! Try it :)
This little command will create a folder with the name `djangogirls` on your desktop. You can check if it's there just by looking on your Desktop or by running a `ls` or `dir` command! Try it :)

> PRO tip: If you don't want to type the same commands over and over, try pressing the `up arrow` and `down arrow` on your keyboard to cycle through recently used commands.

Expand Down
Loading