diff --git a/README.md b/README.md index 74ee2afd010..c5125475b50 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## Introduction -Have you ever felt that world is more and more about technology and you are somehow left behind? Have you ever wondered how to create a website but have never had enough motivation to start? Have you ever thought that software world is too complicated for you to even try doing something on your own? +Have you ever felt that the world is more and more about technology and you are somehow left behind? Have you ever wondered how to create a website but have never had enough motivation to start? Have you ever thought that the software world is too complicated for you to even try doing something on your own? Well, we have good news for you! Programming is not as hard as it seems and we want to show you how fun it could be. -The tutorial will not magically turn you into programmer. If you want to be good at it, you need months or even years of learning and practice. But we want to show you that programming or creating website is not as complicated as it seems. We will try to explain different bits and pieces as good as we can, so you will not feel intimidated by technology. +The tutorial will not magically turn you into programmer. If you want to be good at it, you need months or even years of learning and practice. But we want to show you that programming or creating websites is not as complicated as it seems. We will try to explain different bits and pieces as well as we can, so you will not feel intimidated by technology. We hope that we'll be able to make you love technology as much as we do! diff --git a/css/README.md b/css/README.md index 29d9678ea57..08b9d0be5b6 100644 --- a/css/README.md +++ b/css/README.md @@ -1,6 +1,6 @@ # CSS - make it pretty! -Our blog looks still pretty ugly, right? Time to make it nice! We will use CSS for that. +Our blog still looks pretty ugly, right? Time to make it nice! We will use CSS for that. ## What is CSS? @@ -32,13 +32,13 @@ Looking nicer already! Another thing you will learn about today is called __static files__. Static files are all your CSS and images -- files that are not dynamic, so their content don't depend on request context and will be the same for every user. -CSS is a static file, so in order to customize CSS, we need to first configure static files in Django. You'll only do it once for all. Let's start: +CSS is a static file, so in order to customize CSS, we need to first configure static files in Django. You'll only do it once and for all. Let's start: ### Configure static files in Django First, we need to create a folder to store our static files in. Go ahead and create folder called `static` inside your `mysite` folder. -Now we need to tell Django how it can find it. Open up a `mysite/mysite/settings.py` file, scroll to the bottom of it and add following lines: +Now we need to tell Django how it can find it. Open up the `mysite/mysite/settings.py` file, scroll to the bottom of it and add the following lines: STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), @@ -52,9 +52,9 @@ That's it! Time to see if it works :) First things first: let's create a CSS file now. Create a new folder called `css` inside your `static` folder. Then create a new file called `blog.css` inside this `css` directory. Ready? -Time to write some CSS! Open up your `blog.css` file in code editor. +Time to write some CSS! Open up the `blog.css` file in your code editor. -We won't be going to deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. +We won't be going too deep into customizing and learning about CSS here, because it's pretty easy and you can learn it on your own after this workshop. We really recommend doing this [Codeacademy HTML & CSS course](http://www.codecademy.com/tracks/web) to learn everything you need to know about making your websites more pretty with CSS. But let's do at least a little. Maybe we could change the color of our header? To understand colors, computer use special codes. They start with `#` and are followed by 6 letters and numbers. You can find color codes for example here: http://www.colorpicker.com/ @@ -74,7 +74,7 @@ We're just loading static files here :) Then, in the `` section, add this -We just told our template where our CSS file is located. Ok, save a file and refresh the site! +We just told our template where our CSS file is located. Ok, save the file and refresh the site! ![Figure 14.2](images/color2.png) @@ -84,11 +84,11 @@ Nice work! Maybe we would also like to give our website a little air and increas margin-left: 15px; } -Add this to your CSS, save a file and see how it works! +Add this to your CSS, save the file and see how it works! ![Figure 14.3](images/margin2.png) -Maybe we can customize a font in our header? Paste this into your `` in `post_list.html` file: +Maybe we can customize the font in our header? Paste this into your `` in `post_list.html` file: @@ -181,7 +181,7 @@ Then also replace this: {% endfor %} -in a `` of your `post_list.html` with this: +in the `` of your `post_list.html` with this:
diff --git a/deploy/README.md b/deploy/README.md index b5f3a11a233..11c3d178cf8 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -2,15 +2,15 @@ Until now your website was only available on your computer, now we will learn how to deploy it! Deploying is a process of publishing your application on the Internet so people can finally go and see your app :) -As you learned, website has to be located on the server. There is a lot of providers, but we will use the one with simplest deployment process: [Heroku](http://heroku.com/). Heroku is free for small applications that don't have too much visitors, it'll be definitely enough for you too. +As you learned, a website has to be located on a server. There are a lot of providers, but we will use the one with the simplest deployment process: [Heroku](http://heroku.com/). Heroku is free for small applications that don't have too many visitors, it'll definitely be enough for you too. We will be following this tutorial: https://devcenter.heroku.com/articles/getting-started-with-django, but we pasted it here so it's easier for you. ## Requirements.txt -We need to create a `requirements.txt` file to tell Heroku what Python packages needs to be installed on our server. +We need to create a `requirements.txt` file to tell Heroku what Python packages need to be installed on our server. -But first, Heroku needs us to install `django-toolbelt` package. Go to your console with `virtualenv` activated and type this: +But first, Heroku needs us to install the `django-toolbelt` package. Go to your console with `virtualenv` activated and type this: $ pip install django-toolbelt @@ -22,7 +22,7 @@ This will create a file called `requirements.txt` with a list of your installed ## Procfile -Another thing we need to create is a Profile. Open up your code editor, create a file called `Procfile` in `mysite` directory and add this line: +Another thing we need to create is a Procfile. Open up your code editor, create a file called `Procfile` in `mysite` directory and add this line: web: gunicorn mysite.wsgi @@ -30,7 +30,7 @@ Then save it. Done! ## mysite/settings.py -Another thing we need to modify is our website `settings.py` file. Open `mysite/settings.py` in your editor and add following lines: +Another thing we need to do is modify our website's `settings.py` file. Open `mysite/settings.py` in your editor and add the following lines: import dj_database_url DATABASES['default'] = dj_database_url.config() @@ -41,11 +41,11 @@ Another thing we need to modify is our website `settings.py` file. Open `mysite/ STATIC_ROOT = 'staticfiles' -Then save a file. +Then save the file. ## mysite/urls.py -Open `mysite/urls.py` file and add this two line in the begining of the file: +Open `mysite/urls.py` file and add these two line in the begining of the file: from django.conf.urls.static import static from django.conf import settings @@ -63,7 +63,7 @@ The whole thing should look like this: ## mysite/wsgi.py -Open `mysite/wsgi.py` file and replace this line: +Open the `mysite/wsgi.py` file and replace this line: application = get_wsgi_application() diff --git a/django_-_why_you_need_a_webframework/README.md b/django_-_why_you_need_a_webframework/README.md index 857a75569b8..ff6aea04d07 100644 --- a/django_-_why_you_need_a_webframework/README.md +++ b/django_-_why_you_need_a_webframework/README.md @@ -2,28 +2,28 @@ 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. -You see, when you're building a website, you always need a similiar set of components: a way to handle user authentication (signing up, signing in, signing out), management panel for your website, forms, uploading files, etc, etc. +You see, when you're building a website, you always need a similiar set of components: a way to handle user authentication (signing up, signing in, signing out), management panel for your website, forms, uploading 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 create frameworks (Django is one of them) that gives you ready components you can use. +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 givs you ready components you can use. Frameworks exist to save you from having to re-invent the wheel and help alleviate some of the overhead when you’re building a new site. ## Why do you need a framework? -To understand what Django actually is for, we need a closer look at the servers. First thing is that the server needs to know, that you want it to serve you a webpage. +To understand what Django actually is for, we need a closer look at the servers. First thing is that the server needs to know that you want it to serve you a webpage. -Imagine a mailbox (port) which is monitored for incoming letters (requests). It is done by a web server. The web server also sends the response with webpage. But when you want something to send, you need to have some content. And Django is something that helps you create the content. +Imagine a mailbox (port) which is monitored for incoming letters (requests). It is done by a web server. The web server also sends the response with a webpage. But when you want to send something, you need to have some content. And Django is something that helps you create the content. ## What happen when someone request a website from your server? -When request comes to a web server it passes it to Django. Django tries to figure out what actually is requested. It takes a webpage address used and tries to figure out what to. This part is done by Django's urlresolver (Note that a website address is called URL - Uniform Resource Locator, so the name 'urlresolver' makes sense). It is not very smart here - it takes a list of patterns and tries to match the URL. Django checks patterns from top to the bottom and if something is matched then Django passes the request to the associated function called view. +When a request comes to a web server it passes it to Django. Django tries to figure out what actually is requested. It takes a webpage address used and tries to figure out what to do. This part is done by Django's urlresolver (Note that a website address is called URL - Uniform Resource Locator, so the name 'urlresolver' makes sense). It is not very smart here - it takes a list of patterns and tries to match the URL. Django checks patterns from top to the bottom and if something is matched then Django passes the request to the associated function called view. Imagine a postman with a letter who is walking down the street and checks each house number with the one on the letter. If it matches, they put the letter there. -In 'view' all interesting things are done: we can look at the database to look for some information to return it to user. Maybe user asked to change something in the data? Like a letter saying "Please change description of my job title." - view can check if you are allowed to do that, then update the job title for you and send back a message: "Done!". Then view is generating a response and Django can send it to user's web browser. +In the 'view' all interesting things are done: we can look at the database to look for some information to return it to the user. Maybe the user asked to change something in the data? Like a letter saying "Please change description of my job title." - the view can check if you are allowed to do that, then update the job title for you and send back a message: "Done!". Then the view generates a response and Django can send it to the user's web browser. Of course, the description above is a little bit simplified, but you don't need to know all the technical things yet. Knowing a general idea is enough. -So instead of diving too much into details, we will simply start creating something with Django and we will learn all important parts on the way! +So instead of diving too much into details, we will simply start creating something with Django and we will learn all the important parts along the way! diff --git a/django_admin/README.md b/django_admin/README.md index 3042ee94e2c..ad3cf0afc08 100644 --- a/django_admin/README.md +++ b/django_admin/README.md @@ -1,15 +1,15 @@ # Django admin -To add, edit and delete posts we have just modeled, we will use Django admin. +To add, edit and delete posts we have just modeled, we will use the Django admin. -Let's open `blog/admin.py` file and replace it's content with this: +Let's open `blog/admin.py` file and replace its content with this: from django.contrib import admin from .models import Post admin.site.register(Post) -As you can see, we import (include) Post model defined in the previous chapter. +As you can see, we import (include) the Post model defined in the previous chapter. Ok, time to look at our Post model. Go to the browser and type an address: @@ -19,7 +19,7 @@ You will see a login page like this: ![Login page](images/login_page.png) -You should use username and password you chose when you were creating a database (in "Starting Django project" chapter). After login in, you should see Django admin dashboard. +You should use the username and password you chose when you were creating a database (in "Starting Django project" chapter). After login in, you should see the Django admin dashboard. ![Django admin](images/django_admin.png) @@ -29,8 +29,8 @@ Make sure that at least two or three (but not all) have publish date set. It wil ![Django admin](images/edit_post.png) -If you want to know more about Django admin, you should check Django documentation: https://docs.djangoproject.com/en/dev/ref/contrib/admin/ +If you want to know more about the Django admin, you should check Django's documentation: https://docs.djangoproject.com/en/dev/ref/contrib/admin/ -It is probably the good moment to grab a coffee (or tea) and eat something sweet. You created your first Django model - you deserve a little treat! +It is probably a good moment to grab a coffee (or tea) and eat something sweet. You created your first Django model - you deserve a little treat! diff --git a/django_forms/README.md b/django_forms/README.md index a58dcfee7f1..6b60f6d3e0b 100644 --- a/django_forms/README.md +++ b/django_forms/README.md @@ -1,14 +1,14 @@ # Django Forms -Last thing we want to do with our website is adding some nice way to add and edit blog post. Django `admin` is cool, but it is rather hard to customize. With `forms` we will have absolute power over forms - we can do almost anything we can imagine with it! +The last thing we want to do with our website is to add some nice way to add and edit blog post. Django's '`admin` is cool, but it is rather hard to customize. With `forms` we will have absolute power over forms - we can do almost anything we can imagine with it! -The nice thing about Django forms is that we can either define one from scratch or create a `ModelForm` which will save the result of the form the model. +The nice thing about Django forms is that we can either define one from scratch or create a `ModelForm` which will save the result of the form to the model. This is exactly what we want to do: we will create a form for our `Post`. -As every important part of Django, forms have their own file: `forms.py`. +Like every important part of Django, forms have their own file: `forms.py`. -We need to create a file with this name in `blog` folder. +We need to create a file with this name in the `blog` folder. └── blog └── forms.py @@ -35,7 +35,7 @@ Finally we can say which field should end up in our form. In this scenario we wa And that's it! All we need to do now is use the form in a view and display it in a template. -So once again we will create: link to the page, url, view and template. +So once again we will create: a link to the page, a url, a view and a template. ## Link to page with the form @@ -43,7 +43,7 @@ It's time to open `mysite/template/mysite/base.html`. We will add a link in `div -Note, that we want to call our new view `post_new`. +Note that we want to call our new view `post_new`. After adding the line your html file should look like this now: @@ -79,7 +79,7 @@ After adding the line your html file should look like this now: -After saving and refreshing a page `http://127.0.0.1:8000` you will obviously see a familiar `NoReverseMatch` error, right? +After saving and refreshing the page `http://127.0.0.1:8000` you will obviously see a familiar `NoReverseMatch` error, right? ## Url @@ -98,11 +98,11 @@ And the final code will look like this: url(r'^post/new/$', views.post_new), ) -After refreshing the site, we have `AttributeError`, since we don't have `post_new` view implemented. Let's add it right now. +After refreshing the site, we see an `AttributeError`, since we don't have `post_new` view implemented. Let's add it right now. ## post_new view -Time to open `blog/views.py` file and add following lines: +Time to open the `blog/views.py` file and add the following lines: from .forms import PostForm @@ -116,12 +116,12 @@ To create a new Post form, we need to call `PostForm()` and pass it to the templ ## Template -We need to create a file `post_edit.html` in `blog/template/blog` directory. To make a form work we need several things: +We need to create a file `post_edit.html` in the `blog/template/blog` directory. To make a form work we need several things: - we need to display the form. We can do that for example with a `{{ form.as_p }}`. - the line above have to be wrapped with HTML form tag: <`form method="POST">...` - we need a `Save` button. We do that with HTML: `` -- and finally just after `
` tag we need to add `{% csfr_token %}`. This is very important, since it makes your forms secure! Django will complain if you forget about this bit if you will try to save the form: +- and finally just after the `` tag we need to add `{% csfr_token %}`. This is very important, since it makes your forms secure! Django will complain if you forget about this bit if you try to save the form: ![CSFR Forbidden page](images/csrf.png) @@ -155,7 +155,7 @@ Open `blog/views.py` once again. Currently all we have in `post_new` view is: form = PostForm() return render(request, 'blog/post_edit.html', {'form': form}) -When we submit form, we are back in the same view, but this time we have some more data in `request`, more specifically in `request.POST`. Remember that in HTML file our `` definition had variable `method="POST"`? All the fields from the form are now in `request.POST`. You should not rename `POST` to anything else (the only other valid value for `method` is `GET`, but we have no time to explain what's the difference). +When we submit form, we are back in the same view, but this time we have some more data in `request`, more specifically in `request.POST`. Remember that in HTML file our `` definition had variable `method="POST"`? All the fields from the form are now in `request.POST`. You should not rename `POST` to anything else (the only other valid value for `method` is `GET`, but we have no time to explain what the difference is). So in our view we have two separate situations to handle. First one: when we access the page for the first time and we want a blank form. Second one: when we go back to the view with all form's data we just typed. So we need to add a condition (we will use `if` for that). @@ -177,7 +177,7 @@ We can check if the form is valid and if so, we can save it! post.author = request.user post.save() -Basically we have here two things: we save the form with `form.save` and we add an author (since there was no `author` field in the `PostForm` and this field is required!). `commit=False` means that we don't want to save `post` yet - we want to add author first. Most of the time you will use `form.save()`, without `commit=False`, but in this case, we need to do that. +Basically we have two things here: we save the form with `form.save` and we add an author (since there was no `author` field in the `PostForm` and this field is required!). `commit=False` means that we don't want to save `post` yet - we want to add author first. Most of the time you will use `form.save()`, without `commit=False`, but in this case, we need to do that. `post.save()` preserve changes (with author) and a new blog post is created! Finally, it would be awesome if we can immediatelly go to `post_detail` page for newly created blog post, right? To do that we need more imports: @@ -219,7 +219,7 @@ Django is taking care of validating that all fields in our form are correct. Isn ## Edit form -Now we know how to add new form. But what if we want to edit an existing one? It is very similar to the thing we just did. Let's create quickly important things (if you don't understand something - you should ask your coach or look at th eprevious chapters, since we covered all the steps already). +Now we know how to add new form. But what if we want to edit an existing one? It is very similar to the thing we just did. Let's create some important things quickly (if you don't understand something - you should ask your coach or look at the previous chapters, since we covered all the steps already). Open `blog/post_detail.html` and add this line: @@ -245,7 +245,7 @@ In `blog/urls.py` we add this line: url(r'^post/(?P[0-9]+)/edit/$', views.post_edit, name='post_edit'), -We will reuse template `blog/template/blog/post_edit.html`, so last thing missing is a view. +We will reuse the template `blog/template/blog/post_edit.html`, so last the thing missing is a view. Let's open a `blog/views.py` and add at the very end of the file: diff --git a/django_installation/README.md b/django_installation/README.md index ff352e509dd..d7ecb11bbb2 100644 --- a/django_installation/README.md +++ b/django_installation/README.md @@ -4,7 +4,7 @@ ## Virtual environment -Before we will install Django, we will make you install something very handy and useful, that will help you with keeping everything tidy on your computer. It is possible to skip this step, but we think, that you should start with the best setup possible to save a lot of troubles in a future. +Before we will install Django, we will make you install something very handy and useful, that will help you with keeping everything tidy on your computer. It is possible to skip this step, but we think, that you should start with the best setup possible to save a lot of troubles in the future. That's why we want you to create a Virtual environment (also called `virtualenv`). It will isolate things you do from your computer, so you will have everything important in one place. Neat, right? @@ -12,7 +12,7 @@ All you need to do is find a folder in which you want to create the `virtualenv` ### Windows -To create `virtualenv` you need to open command line `cmd` and type there `C:\Python\python -m venv blog`. It will look like this: +To create `virtualenv` you need to open the command line `cmd` and type there `C:\Python\python -m venv blog`. It will look like this: C:\Users\Name> C:\Python34\python -m venv blog diff --git a/django_models/README.md b/django_models/README.md index ca1110f0c78..a51b49287db 100644 --- a/django_models/README.md +++ b/django_models/README.md @@ -30,11 +30,11 @@ And then the `Cat` has some actions: `purr`, `scratch` or `feed` (in which we wi So basically the idea is to describe real things in code with properties (called `object properties`) and actions (called `methods`). -How we will model blog post then? Since we want to build a blog, right? +How will we model blog posts then? Since we want to build a blog, right? -We need to answer a question: what is a blog post? What properties it should have? +We need to answer a question: what is a blog post? What properties should it have? -Well, for sure our blog post needs some text with content and a title, right? It also would be nice to know, who wrote it - we need an author then. Finally, we also want to know when the post was created and published. +Well, for sure our blog post needs some text with content and a title, right? It also would be nice to know who wrote it - we need an author then. Finally, we also want to know when the post was created and published. Post -------- @@ -52,9 +52,9 @@ Since we already know what we want to achieve, we can start modelling it in Djan ## Django model -Knowing what object is, we can create a Django model for our blog post. +Knowing what an object is, we can create a Django model for our blog post. -Model in Django is a special kind of object - it is saved in `database`. And database is something that stores data for us. +A model in Django is a special kind of object - it is saved in the `database`. And the database is something that stores data for us. ### Creating an application @@ -77,7 +77,7 @@ You will notice that a new `blog` folder is created and it contains a number of ├── tests.py └── views.py -After creating an application we also need to say Django that it should use it. We do that in a file `mysite/setting.py`. We need to find `INSTALLED_APPS` and add a line `blog` just above `)`. We should also add `mysite` application (which was created for us when we started a new project in last chapter). So the final product should look like this: +After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/setting.py`. We need to find `INSTALLED_APPS` and add a line `blog` just above `)`. We should also add `mysite` application (which was created for us when we started a new project in last chapter). So the final product should look like this: INSTALLED_APPS = ( 'django.contrib.admin', @@ -118,32 +118,32 @@ Let's open `blog/models.py`, remove everything from it and write code like this: It is scary, right? But no worries, we will explain what these lines mean! -All lines started with `from` or `import` are lines that adds some bits from other files. So instead of copy and paste the same things in every file, we can include some parts with `from ... import ...`. +All lines started with `from` or `import` are lines that adds some bits from other files. So instead of copying and pasting the same things in every file, we can include some parts with `from ... import ...`. `class Post(models.Model):` - this line defines our model. - `class` is a special keyword that indicates that we are defining an object. -- `Post` is a name of model, we can call it differently (but we have to avoid special characters and whitespaces). Always start a name with uppercase. -- `models.Model` means that the Post is a Django Model, so it will be saved in database. +- `Post` is the name of our model, we can call it differently (but we have to avoid special characters and whitespaces). Always start a name with uppercase. +- `models.Model` means that the Post is a Django Model, so it will be saved in the database. Now we define properties we where talking about: `title`, `text`, `created_date`, `published_date` and `author`. To do that we need to define a type of field (is it a text? a number? a relation to another object, i.e. a User? date?). - `models.CharField` - this is how you define text with 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.DateTimeField` - this is a date -- `models.ForeignKey` - this is a link to other model +- `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 documentation, if you need to know more about Model fields (properties) and how to define things other than things described above (https://docs.djangoproject.com/en/dev/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 need to know more about Model fields (properties) and how to define things other than things described above (https://docs.djangoproject.com/en/dev/ref/models/fields/#field-types). -What about `def publish(self):`? It is exactly our `publish` method we were talking about. `def` means that this is a function/method. `publish` is a 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 method that calculates avarage price you could call it `calculate_avarage_price`). +What about `def publish(self):`? It is exactly our `publish` method we were talking about. `def` means that this is a function/method. `publish` is a 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 method that calculates average price you could call it `calculate_average_price`). -Method very often `return` something. There is an example of that in `__unicode__` method. In this scenario, when we call `__unicode__()` we will get a text (**string**) with a Post title. +Methods very often `return` something. There is an example of that in the `__unicode__` method. In this scenario, when we call `__unicode__()` we will get a text (**string**) with a Post title. -If something is still not clear about models, feel free to ask you coach! We know, it is very complicated, especially when you learn what object and function (method) is at the same time. But hopefully, it looks sligthly less magic for you now! +If something is still not clear about models, feel free to ask you coach! We know, it is very complicated, especially when you learn what objects and functions (method) are at the same time. But hopefully, it looks sligthly less magic for you now! ### Create a database for your models -Last step here is to add model to our database. It is as easy as typing `python manage.py syncdb`. It will look like this: +Last step here is to add our new model to our database. It is as easy as typing `python manage.py syncdb`. It will look like this: (blog) ~/mysite python manage.py syncdb Creating tables ... diff --git a/django_orm_querysets/README.md b/django_orm_querysets/README.md index cb741ffd683..c289468ba57 100644 --- a/django_orm_querysets/README.md +++ b/django_orm_querysets/README.md @@ -1,8 +1,8 @@ # Django Querysets -We have different pieces in place: `Post` model is defined in `models.py`, we have `post_list` in `views.py` and the template added. But how actually we will make our posts to appear in our `HTML` template? Because that is what we want: take a content (models saved in database) and display it nicely in our template, right? +We have different pieces in place: the `Post` model is defined in `models.py`, we have `post_list` in `views.py` and the template added. But how will we actually make our posts appear in our `HTML` template? Because that is what we want: take a content (models saved in the database) and display it nicely in our template, right? -This is exactly what `views` suppose to do: connect models and templates. In our `post_list` we will need to take models we want to display and pass them to the template. So basically in a view we decide what (model) will be displayed in a template. +This is exactly what `views` are supposed to do: connect models and templates. In our `post_list` we will need to take the models we want to display and pass them to the template. So basically in a view we decide what (model) will be displayed in a template. Ok, so how we will achieve it? @@ -20,23 +20,23 @@ Remember when we talked about including code written in different files? Now is Dot after `from` means *current folder* or *current application*. Since `views.py` and `models.py` are in the same directory we can simply use `.` and the name of the file (without `.py`). The we import the name of the model (`Post`). -But what next? To take actual blog posts from Post models we need something called `Queryset`. +But what's next? To take actual blog posts from Post models we need something called a `Queryset`. ## Queryset -So now we are interested in a list of blog posts, right? But all we have is model `Post`. Queryset will give us a collection we are looking for. All we need to do to get all posts is: +So now we are interested in a list of blog posts, right? But all we have is model `Post`. A Queryset will give us the collection we are looking for. All we need to do to get all posts is: Post.objects.all() And we have our first queryset! Now we can take each element of it and display it or do something else with it. -But before we will pass queryset to the template and display blog posts we will do some magic and we will select only posts that are published (they have a `published_date` set). +But before we will pass this queryset to the template and display blog posts we will do some magic and we will select only posts that are published (they have a `published_date` set). -Here comes a `filter`. We will use it instead of `all` in a previous line of code. In parentesis we will state what condition need to be met to end up in our queryset. In our situation it is `published_date` that is not empty. The way to write it in Django is: `published_date__isnull=False` (`null` in programming means *empty*). +Here comes a `filter`. We will use it instead of `all` in a previous line of code. In parentheses we will state what condition needs to be met to end up in our queryset. In our situation it is `published_date` that is not empty. The way to write it in Django is: `published_date__isnull=False` (`null` in programming means *empty*). Post.objects.filter(published_date__isnull=False) -Finally, it would be good to have our posts ordered by publish date, right? We can do that with `order_by`. In parentesis we will type (in quotation marks `''`) a name of the field (`published_date`). Our final queryset looks like this: +Finally, it would be good to have our posts ordered by publish date, right? We can do that with `order_by`. In parentheses we will type (in quotation marks `''`) a name of the field (`published_date`). Our final queryset looks like this: Post.objects.filter(published_date__isnull=False).order_by('published_date') @@ -52,7 +52,7 @@ Time to put this piece of code inside `post_list`, right? Please note that we create an *alias* or a *container* for our queryset `posts`. Treat it as a name of our queryset. From now on we can refer to it by this name. The last missing part is to pass the `posts` queryset to the template (we will cover how to display it in a next chapter). -In `render` function we already have parameter with `request` (so everything we receive from the user via internet) and a template file `'blog/post_list.html'`. The last parameter, which looks like this now: `{}` is a place in which we can pass some things to template. We need to give them names (we will stick with `'posts'` right now :)). It should look like this: `{'posts': posts}`. +In the `render` function we already have parameter with `request` (so everything we receive from the user via internet) and a template file `'blog/post_list.html'`. The last parameter, which looks like this now: `{}` is a place in which we can pass some things to template. We need to give them names (we will stick with `'posts'` right now :)). It should look like this: `{'posts': posts}`. So finally our `views.py` file should look like this: diff --git a/django_templates/README.md b/django_templates/README.md index 3c03705c98f..b296e5c59b9 100644 --- a/django_templates/README.md +++ b/django_templates/README.md @@ -4,7 +4,7 @@ Time to display some data! Django gives us some helpful, built-in __template tag ## What are template tags? -You see, in HTML, you can't really put Python code, because browsers don't understand it. They only know HTML. We know, that HTML is rather static, while Python is much more dynamic. +You see, in HTML, you can't really put Python code, because browsers don't understand it. They only know HTML. We know that HTML is rather static, while Python is much more dynamic. __Django template tags__ allow us to transfer Python-like things into HTML, so you can build dynamic websites faster and easier. Yikes! @@ -12,11 +12,11 @@ __Django template tags__ allow us to transfer Python-like things into HTML, so y In previous chapter we gave our template a list of posts in a `posts` variable. Now we will display it in HTML. -To print a variable in Django template, we use double curly brackets with variable name inside, like this: +To print a variable in Django template, we use double curly brackets with the variable's name inside, like this: {{ posts }} -Try this in your `post_list.html` template, save file and refresh page to see results: +Try this in your `post_list.html` template, save the file and refresh the page to see the results: ![Figure 13.1](images/step1.png) @@ -34,7 +34,7 @@ Try this in your template. ![Figure 13.2](images/step2.png) -It works! But we want them to be display in a way we created earlier, like the static posts we put there before. You can mix HTML and template tags. Our `body` will look like that: +It works! But we want them to be displayed in a way we created earlier, like the static posts we put there before. You can mix HTML and template tags. Our `body` will look like that:

Django Girls Blog

@@ -52,7 +52,7 @@ Everything you put between {% for %} and {% endfor %} will be repeated for each ![Figure 13.3](images/step3.png) -Congrats! Now go ahead and try add a new post in your Django admin, then refresh your page to see if post appeared there. +Congrats! Now go ahead and try adding a new post in your Django admin, then refresh your page to see if the post appeared there. Works like a charm? We're proud! Treat yourself something sweet, you have earned it :) diff --git a/django_urls/README.md b/django_urls/README.md index 9a2988af15a..8adaa61d0fc 100644 --- a/django_urls/README.md +++ b/django_urls/README.md @@ -4,15 +4,15 @@ We're about to build our first webpage -- a homepage for your blog! But first, l ## What is URL? -URL is nothing else like web address, you can see an URL every time you any website - it is visible in your browser's address bar: +A URL is simply like a web address, you can see a URL every time you visit any website - it is visible in your browser's address bar: ![Url](images/url.png) -Every page on the internet needs its own URL. This way your application knows what it should show to the user who open an URL. In Django we use something called `URLconf` (URL configuration), which is a set of patterns that Django will try to match to received URL to find correct view. +Every page on the internet needs its own URL. This way your application knows what it should show to the user who opens a URL. In Django we use something called `URLconf` (URL configuration), which is a set of patterns that Django will try to match with the received URL to find the correct view. ## How URLs work in Django? -Let's open up a `mysite/urls.py` file and see how it looks: +Let's open up the `mysite/urls.py` file and see how it looks: from django.conf.urls import patterns, include, url @@ -31,7 +31,7 @@ As you can see, Django already put something for us here. Lines that starts with `#` are comments - it means that those lines won't be executed by Python. Pretty handy, right? -Admin url, which you visited in previous chapter is already here: +The admin url, which you visited in previous chapter is already here: url(r'^admin/', include(admin.site.urls)), @@ -39,7 +39,7 @@ It means that for every url that starts with `admin/` Django will find a corresp ## Regex -Do you wonder how Django matches URLs to views? Well, this part is tricky. Django uses `regex` -- regular expression. Regex has a a lot (a lot!) of rules that forms a search pattern. It is not so easy to understand so we won't worry about it today and you'll definitely get to know them in the future. Today we will only use the ones we need. +Do you wonder how Django matches URLs to views? Well, this part is tricky. Django uses `regex` -- regular expressions. Regex has a a lot (a lot!) of rules that forms a search pattern. It is not so easy to understand so we won't worry about it today and you'll definitely get to know them in the future. Today we will only use the ones we need. ## Your first Django url! @@ -83,7 +83,7 @@ As you can see, we're now assigning `view` called `post_list` to `^$` URL. But w If you put this two signs together, it looks like we're looking for empty string! And that's correct, because in Django url resolvers, `http://127.0.0.1:8000/` is not a part of URL. This pattern will show Django that `views.post_list` is the right place to go if someone enter your website on `http://127.0.0.1:8000/` address. -Everything all right? Open http://127.0.0.1:8000/ in our browser to see results. +Everything all right? Open http://127.0.0.1:8000/ in your browser to see the result. ![Error](images/error1.png) diff --git a/django_views_-_time_to_create/README.md b/django_views_-_time_to_create/README.md index 4905823d960..c5ec721b79a 100644 --- a/django_views_-_time_to_create/README.md +++ b/django_views_-_time_to_create/README.md @@ -2,7 +2,7 @@ Time to get rid of the bug we created in last chapter :) -View is where put the "logic" of our application. It will request information from `model` you created before and pass it to a `template` that you will create in next chapter. Views are just Python methods that are a little bit more complicated than what we did in "Introduction to Python" chapter. +A view is where put the "logic" of our application. It will request information from the `model` you created before and pass it to a `template` that you will create in next chapter. Views are just Python methods that are a little bit more complicated than what we did in "Introduction to Python" chapter. Views are placed in `mysite/blog/views.py` file. @@ -22,7 +22,7 @@ Not too much stuff here yet. The simplest view can look like that. As you can see, we created a method (`def`) called `post_list` that takes `request` and `return` a method `render` that will render (put together) our template `blog/post_list.html`. Easy, right? -Save a file, go to http://127.0.0.1:8000/ and see what we got know. +Save the file, go to http://127.0.0.1:8000/ and see what we got now. Another error! Read what's going on now: diff --git a/domain/README.md b/domain/README.md index 07d420f0140..467c49fd523 100644 --- a/domain/README.md +++ b/domain/README.md @@ -6,9 +6,9 @@ In this chapter we will teach you how to buy a domain and direct it to Heroku! ## Where to register a domain? -Typical domain costs around $15 a year. There are cheaper and more expensive options, depending on the provider. There is a lot of companies that you can buy a domain from, simple [google search](https://www.google.pl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=register%20domain) give hundreds of options. +A typical domain costs around $15 a year. There are cheaper and more expensive options, depending on the provider. There are a lot of companies that you can buy a domain from: a simple [google search](https://www.google.pl/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=register%20domain) give hundreds of options. -Our favourite one is [I want my name](https://iwantmyname.com/). They advertise as "painless domain management" and it really is painless. We asked them if they want to support Django Girls and they gave us a 20% discount code for you! :) As organizers or coaches for it! +Our favourite one is [I want my name](https://iwantmyname.com/). They advertise as "painless domain management" and it really is painless. We asked them if they wanted to support Django Girls and they gave us a 20% discount code for you! :) Ask organizers or coaches for it! ## How to register domain in IWantMyName? @@ -16,7 +16,7 @@ Go to [iwantmyname](http://iwantmyname.com) and type a domain you want to have i ![](images/1.png) -You should now see a list of all available domains with the term you put in search box. As you can see, smiley face indicate tht domain is available for buy, and sad face that this is already taken. +You should now see a list of all available domains with the term you put in the search box. As you can see, a smiley face indicate that the domain is available for you to buy, and a sad face that it is already taken. ![](images/2.png) @@ -24,7 +24,7 @@ We've decided to buy `djangogirls.in`: ![](images/3.png) -Go to a checkout. You should now sign up for iwantmyname if you don't have your account yet. After that, provide your discount code, credit card info and buy a domain! +Go to checkout. You should now sign up for iwantmyname if you don't have your account yet. After that, provide your discount code, credit card info and buy a domain! After that, click into `Domains` in menu and choose your newly purchased domain. Then locate and click on `manage DNS records` link: diff --git a/extend_your_application/README.md b/extend_your_application/README.md index 74c9e7f737d..f206ebe8c6a 100644 --- a/extend_your_application/README.md +++ b/extend_your_application/README.md @@ -1,6 +1,6 @@ # Extend your application -We already conpleted all different steps in creation of our website: we know how to write a model, url, view and template. We also know how to make our website pretty. +We've' already completed all the different steps necessary for the creation of our website: we know how to write a model, url, view and template. We also know how to make our website pretty. Time to practice! @@ -24,27 +24,27 @@ We will start with adding a link inside `post_list.html` (in `blog/template/blog -We want to have a link to post detail page on post title. Let's change `

{{ post.title }}

` with link: +We want to have a link to a post detail page on the post's title. Let's change `

{{ post.title }}

` with a link:

{{ post.title }}

-Time to explain mysterious `{% url 'blog.views.post_detail' pk=post.pk %}`. As you suspect `{% %}` notation means that we are using Django template tags. This time we will use one that will create an URL for us! +Time to explain mysterious `{% url 'blog.views.post_detail' pk=post.pk %}`. As you suspect `{% %}` notation means that we are using Django template tags. This time we will use one that will create a URL for us! -`blog.views.post_detail` is a path to a `post_detail` view we want to create. Please note: `blog` is a name of our application (in folder `blog`), `views` is from name of `views.py` file and last bit: `post_detail` is a name of view. +`blog.views.post_detail` is a path to a `post_detail` view we want to create. Please note: `blog` is the name of our application (in folder `blog`), `views` is from the name of the `views.py` file and the last bit: `post_detail` is the name of the view. Now when we go to: http://127.0.0.1:8000/ -we will have an error (as suspected, since we don't have url or view for `post_detail`). It will look like this: +we will have an error (as suspected, since we don't have a url or a view for `post_detail`). It will look like this: ![NoReverseMatch error](images/no_reverse_match.png) -Let's create an url in `urls.py` for our `post_detail` view! +Let's create a url in `urls.py` for our `post_detail` view! ### URL: http://127.0.0.1:8000/post/1/ -We now want to create an URL to point Django to view called `post_detail`, that will show entire blog post. Add line `url(r'^post/(?P[0-9]+)/$', views.post_detail),` to `urls.py` file. It should look like this: +We now want to create a URL to point Django to a view called `post_detail`, that will show an entire blog post. Add the line `url(r'^post/(?P[0-9]+)/$', views.post_detail),` to the `urls.py` file. It should look like this: from django.conf.urls import patterns, include, url @@ -58,16 +58,16 @@ We now want to create an URL to point Django to view called `post_detail`, that That one looks scary, but no worries - we will explain it for you: - it's starts with `^` again -- "the beginning" -- `post/` only means that after the beginning, URL should contain the word __post__ and __/__. So far so good. -- `(?P[0-9]+)` - this part is trickier. It means that Django will take everything that you'll place here and transfer it to a view as a variable called `pk`. `[0-9]` also tells us that it can only be a number, not a letter (so everything between 0 and 9). `+` menas that there need to be one or more digits there. So something like `http://127.0.0.1:8000/post//` is not valid, but `http://127.0.0.1:8000/post/1234567890/` is perfectly ok! +- `post/` only means that after the beginning, the URL should contain the word __post__ and __/__. So far so good. +- `(?P[0-9]+)` - this part is trickier. It means that Django will take everything that you'll place here and transfer it to a view as a variable called `pk`. `[0-9]` also tells us that it can only be a number, not a letter (so everything between 0 and 9). `+` means that there needs to be one or more digits there. So something like `http://127.0.0.1:8000/post//` is not valid, but `http://127.0.0.1:8000/post/1234567890/` is perfectly ok! - `/` - then we need __/__ again - `$` - "the end"! That means if you enter `http://127.0.0.1:8000/post/5/` into your browser, Django will understand that you look for a view called `post_detail` and transfer the information that `pk` equals `5`. -`pk` is shortcut from `primary key`. This name is vary often used in many Django projects. But you can name your variable as you like (remember: lowercase and `_` instead of whitespaces!). For example instead of `(?P[0-9]+)` we could have variable `post_id`, so this bit would look like: `(?P[0-9]+)`. +`pk` is shortcut from `primary key`. This name is very often used in many Django projects. But you can name your variable as you like (remember: lowercase and `_` instead of whitespaces!). For example instead of `(?P[0-9]+)` we could have variable `post_id`, so this bit would look like: `(?P[0-9]+)`. -Ok! Let's refresh a page: +Ok! Let's refresh the page: http://127.0.0.1:8000/ @@ -75,11 +75,11 @@ Boom! Yet another error! As expected! ![AttributeError](images/attribute_error.png) -Do you remember, what is a next step? Of course, adding a view! +Do you remember what the next step is? Of course: adding a view! ## post_detail view -This time our view is given an extra parameter `pk`. Our view need to catch it, right? So we will define our function as `def post_detail(request, pk):`. Note that we need to use exactly the same name as the one we specified in urls (`pk`). Ommiting this variable is also incorrect! +This time our view is given an extra parameter `pk`. Our view needs to catch it, right? So we will define our function as `def post_detail(request, pk):`. Note that we need to use exactly the same name as the one we specified in urls (`pk`). Ommiting this variable is also incorrect! Now, we want to get one and only one blog post. To do this we can use querysets like this: @@ -97,17 +97,17 @@ The good news is that you actually can create your own `Page not found` page and Ok, time to add a view to our `views.py` file! -We should open `blog/views.py` and add a following code: +We should open `blog/views.py` and add the following code: from django.shortcuts import render, get_object_or_404 -Near other `from` lines. And at the end of the file we will ad our view: +Near other `from` lines. And at the end of the file we will add our view: def post_detail(request, pk): post = get_object_or_404(Post, pk=pk) return render(request, 'blog/post_detail.html', {'post': post}) -Yes. It is time to refresh a page: +Yes. It is time to refresh the page: http://127.0.0.1:8000/ @@ -135,9 +135,9 @@ It will look like this:

{{ post.text }}

{% endblock %} -Once again we are extending `base.html`. In `content` block we want to display post's published_date (if exists), title and text. But we should discuss some important things, right? +Once again we are extending `base.html`. In `content` block we want to display a post's published_date (if it exists), title and text. But we should discuss some important things, right? -`{% if ... %} ... {% endif %}` is a templatetag we can use when we want to check something. In this scenario we want to check if post's `published_date` is not empty. +`{% if ... %} ... {% endif %}` is a templatetag we can use when we want to check something. In this scenario we want to check if a post's `published_date` is not empty. Ok we can refresh our page and see if `Page not found` is gone now. diff --git a/homework_add_more_to_your_website/README.md b/homework_add_more_to_your_website/README.md index fd80f7955b5..6ed5082ffc8 100644 --- a/homework_add_more_to_your_website/README.md +++ b/homework_add_more_to_your_website/README.md @@ -63,9 +63,9 @@ into these ones: Publish {% endif %} -As you noticed, we added `{% else %}` line here. That means, that if the condition from `{% if post.published_date %}` is not fulfilled (so if there is no `published_date`), then we want to do the line `Publish`. Note that we are passing `pk` variable in the `{% url %}`. +As you noticed, we added `{% else %}` line here. That means, that if the condition from `{% if post.published_date %}` is not fulfilled (so if there is no `published_date`), then we want to do the line `Publish`. Note that we are passing a `pk` variable in the `{% url %}`. -Time to create an url (in `blog/urls.py`): +Time to create a url (in `blog/urls.py`): url(r'^post/(?P[0-9]+)/publish/$', views.post_publish, name='post_publish'), @@ -82,9 +82,9 @@ Remember, when we created a `Post` model we wrote a method `publish`. It looked self.published_date = timezone.now() self.save() -Now we are finally can use this! +Now we can finally use this! -And once again after publishing the post we are immediatelly go to `post_detail` page! +And once again after publishing the post we are immediately redirected to the `post_detail` page! ![Publish button](images/publish.png) @@ -109,7 +109,7 @@ Now, time for a view! Open `blog/views.py` and add this code: post.delete() return HttpResponseRedirect(reverse(post_list)) -The only new thing is actual deleting a post. Every Django model can be deleted by `.delete()`. It is as simple as that! +The only new thing is to actually delete a post. Every Django model can be deleted by `.delete()`. It is as simple as that! And this time, after deleting a post we want to go to the webpage with a list of posts, so we are using `HttpResponseRedirect`. diff --git a/how_the_internet_works/README.md b/how_the_internet_works/README.md index 1372c4c5a8c..97ab89bd873 100644 --- a/how_the_internet_works/README.md +++ b/how_the_internet_works/README.md @@ -2,22 +2,22 @@ *This chapter is inspired by a talk "How the Internet works" by Jessica McKellar (http://web.mit.edu/jesstess/www/).* -We bet you use the Internet every day. But do you actually know what happens when you type an address like http://djangogirls.org in your browser and click 'Enter'? +We bet you use the Internet every day. But do you actually know what happens when you type an address like http://djangogirls.org in your browser and press 'Enter'? -First thing you need to understand is that website is just a bunch of files saved on a computer disk. Just like your movies, music or pictures. -There is one part that it's unique for websites: they include computer code called HTML. +First thing you need to understand is that a website is just a bunch of files saved on a computer disk. Just like your movies, music or pictures. +There is one part that is unique for websites: they include computer code called HTML. -If you're not familiar with programming, it can be hard to grasp at first, but your web browsers (like Chrome, Safari, Firefox or else) love HTML. Web browsers are designed to understand this code, -follow the instructions and present all this files that your website is made of exactly the way you want them to be presented. +If you're not familiar with programming, it can be hard to grasp at first, but your web browsers (like Chrome, Safari, Firefox, etc) love HTML. Web browsers are designed to understand this code, +follow the instructions and present all these files that your website is made of exactly the way you want them to be presented. -As every file, we need to store files somewhere on a computer disks. For the Internet, we use a special, powerful computers called servers. They don't have -a screen, mouse or a keyboard, because they main purpose is to store data and serve it. That's why they're all called *servers* -- because they *serve* you data. +As every file, we need to store files somewhere on a computer disk. For the Internet, we use special, powerful computers called servers. They don't have +a screen, mouse or a keyboard, because their main purpose is to store data and serve it. That's why they're all called *servers* -- because they *serve* you data. The Internet looks like this: ![Figure 1.1](images/internet_1.png) -Looks like a mess, right? But in fact it is a network of connected machines (servers). Hundreds of thousands of machines. Many, many kilometers of cables around the world! You can see Submarine Cable Map website (http://submarinecablemap.com/) to see how complicated the net is. Here is a screenshot from the website: +Looks like a mess, right? But in fact it is a network of connected machines (servers). Hundreds of thousands of machines. Many, many kilometers of cables around the world! You can see the Submarine Cable Map website (http://submarinecablemap.com/) to see how complicated the net is. Here is a screenshot from the website: ![Figure 1.2](images/internet_3.png) @@ -35,12 +35,12 @@ Your letter goes to the post office. Then it goes to another that is nearer your Yes, it is as simple as that. You send messages and you expect some response. Of course, instead of paper and pen you use bytes of data, but the idea is the same! -Instead of address with street name, city, zipcode and country, we use IP addresses. Your computer asks DNS (Domain Name System) first to translate djangogirls.org into IP address. It works a little bit like old-fashioned phonebooks where you could look for the name of the person and find their phone number. +Instead of address with street name, city, zipcode and country, we use IP addresses. Your computer asks DNS (Domain Name System) first to translate djangogirls.org into an IP address. It works a little bit like old-fashioned phonebooks where you could look for the name of the person and find their phone number. -When you send a letter it needs to have certain features to be delivered correctly: address, postmark etc.. You also use language that the receiver understand, right? The same is with data packets you send in order to see a website: you use protocol called HTTP (HyperText TransferProtocol). +When you send a letter it needs to have certain features to be delivered correctly: address, postmark etc.. You also use language that the receiver understands, right? The same is with data packets you send in order to see a website: you use a protocol called HTTP (HyperText TransferProtocol). -So basically, when you have a website you need to have a server (machine) on which it is. Server is waiting for any incoming requests (letters that ask you to send your website) and it sends back your website (in another letter). +So basically, when you have a website you need to have a server (machine) on which it is. The server is waiting for any incoming requests (letters that ask you to send your website) and it sends back your website (in another letter). -Since it is a Django tutorial, you will ask what Django does? When you send a response you don't always want to send the same thing to everybody. It is so much better if your letter is personalized especially for the person that has just wrote to you. Django helps you with creating this personalized, interesting letters :). +Since it is a Django tutorial, you will ask what Django does? When you send a response you don't always want to send the same thing to everybody. It is so much better if your letter are personalized especially for the person that has just written to you. Django helps you with creating these personalized, interesting letters :). Enough talking, time to create! diff --git a/html/README.md b/html/README.md index 132914ab59e..3d25920646c 100644 --- a/html/README.md +++ b/html/README.md @@ -56,7 +56,7 @@ Save a file and refresh your website. ![Figure 11.3](images/step4.png) -You can that browser understood that "Ola's blog" should be a title of your website? Nice! +You can that browser understood that "Ola's blog" should be the title of your website? Nice! You should have also noticed that you have to nest your tags and always close them with the same tag containing `/`. Otherwise browser won't understand you. @@ -101,7 +101,7 @@ We've built something like this: We've created three `div` sections here. -- First `div` contain the title of our blog that is a header and is clickable +- The first `div` contains the title of our blog that is a header and is clickable - Another two `div`s contain our blogposts with a `small` published date, `h2` with a post title that is clickable and a `p` (paragraph) of text, which is our blogpost. It gives us this effect: diff --git a/install_python/README.md b/install_python/README.md index 0daa3928410..a7f066be2b0 100644 --- a/install_python/README.md +++ b/install_python/README.md @@ -4,7 +4,7 @@ Huh, it's exciting, right?! You'll write your first line of code in just minutes But first, let me tell you what Python is. Python is a very popular programming language that can be used to write websites, games, science, graphics, and many, many more. -Python was conceived in the late 1980s and it's main goal is to be readable by human beings (not only machines!) that's why it looks much simpler than other programming laungages. That also makes it easy to learn, but don't worry, Python is also really powerful! +Python was conceived in the late 1980s and its main goal is to be readable by human beings (not only machines!) that's why it looks much simpler than other programming languages. That also makes it easy to learn, but don't worry, Python is also really powerful! # Python installation @@ -14,16 +14,16 @@ Django is written in Python. We need it to do anything in Django. Let's start wi ### Windows -You can download Python for Windows from website https://www.python.org/download/releases/3.4.0/. After downloading ***.msi** file, you should execute it (double-click on it) and follow the instructions there. It is important to remember the path (the folder) where we installed the Python. It will be needed later. +You can download Python for Windows from the website https://www.python.org/download/releases/3.4.0/. After downloading the ***.msi** file, you should execute it (double-click on it) and follow the instructions there. It is important to remember the path (the folder) where we installed Python. It will be needed later. ### Linux -It is very probable, that you already have Python installed out of the box. To check if you have it installed (and which version it is), you type in a console: +It is very likely that you already have Python installed out of the box. To check if you have it installed (and which version it is), you type in a console: $ python --version Python 3.4.0 -If you don't have Python installed or you want different version, you can install it as follows. +If you don't have Python installed or you want a different version, you can install it as follows. #### Ubuntu @@ -44,4 +44,4 @@ You need to go to the website https://www.python.org/downloads/release/python-34 ---- -If you have any doubts or something went wrong and you have no idea what to do next - please ask your coach! Sometimes things are not going smoothly and it's better to ask for help someone with more experience. +If you have any doubts or something went wrong and you have no idea what to do next - please ask your coach! Sometimes things are not going smoothly and it's better to ask for help from someone with more experience. diff --git a/starting_django_project/README.md b/starting_django_project/README.md index f9be3e59b4a..af92371df63 100644 --- a/starting_django_project/README.md +++ b/starting_django_project/README.md @@ -4,9 +4,9 @@ Let's build a simple blog! -The first step to create it is starting a new Django project. Basically that means that we will run some script from Django that will create for us a skeleton of Django project: bunch of directories and files that we will later use. +The first step to create it is starting a new Django project. Basically that means that we will run some script from Django that will create for us a skeleton of a Django project: bunch of directories and files that we will later use. -Names of some files and directories are very important for Django. You should not rename files that we are about to create. Moving them to different place is also not a good idea. Django needs a certain folder/files structure to be able to find important things. +The names of some files and directories are very important for Django. You should not rename files that we are about to create. Moving them to different place is also not a good idea. Django needs a certain folder/files structure to be able to find important things. In console/command-line you should type: @@ -30,7 +30,7 @@ File `settings.py` contains a configuration of your website. Remember when we talked about a postman checking where to deliver a letter? `urls.py` file contains a list of patterns used by `urlresolver`. -Let's ignore for now other files - we will not change them, so we will skip expalining what they actually do. The only thing to remember is to not delete them by accident! +Let's ignore the other files for now - we will not change them, so we will skip explaining what they actually do. The only thing to remember is to not delete them by accident! ## Changing settings @@ -43,9 +43,9 @@ It would be nice to have a correct time on our website. You should find lines th ## Creating a database -Most of web application have their own database. Database is a collection of data. This is a place in which you will store all information about users, all your blog post texts, etc.. +Most of web application have their own database. A database is a collection of data. This is a place in which you will store all information about users, all your blog post texts, etc.. -There is number of different database systems that store data for you. We will use one of the simpliest: `sqlite3`, which was installed with Django. But if you plan to do some serious websites in a future we recommends looking at `PostgreSQL`. +There is a number of different database systems that store data for you. We will use one of the simpliest: `sqlite3`, which was installed with Django. But if you plan to do some serious websites in the future we recommend looking at `PostgreSQL`. To create a database for our blog we will type in console/command-line `python manage.py syncdb`. It should look like this: @@ -81,14 +81,14 @@ You need to be in a folder that contains `manage.py` file (in `mysite` directory (blog) ~/mysite python manage.py runserver -Now all you need to do is checking if your website is running :). Open your browser (Firefox, Chrome, Safari, Internet Explorer or whatever you use) and type the address: +Now all you need to do is to check if your website is running :). Open your browser (Firefox, Chrome, Safari, Internet Explorer or whatever you use) and type the address: http://localhost:8000/ -Congratulations! You created your first website and run it using web server! Isn't it awesome? +Congratulations! You've just created your first website and run it using a web server! Isn't it awesome? ![It worked!](images/it_worked.png) -Ready for next steps? It's time to create a content! +Ready for the next steps? It's time to create some content! diff --git a/template_extending/README.md b/template_extending/README.md index c304aa1a0c7..f54119f08ad 100644 --- a/template_extending/README.md +++ b/template_extending/README.md @@ -1,12 +1,12 @@ # Template extending -Another nice thing Django prepared for you is __template extending__. What it means? It means that you can use the same parts of your HTML for different pages of your website. +Another nice thing Django prepared for you is __template extending__. What does it mean? It means that you can use the same parts of your HTML for different pages of your website. This way you don't have to write it every time, you don't repeat yourself and if you want to change something, you don't have to do it in every template, just once! ## Create base template -Base template is the most basic template that you then use to extend it on every page of your website. +A base template is the most basic template that you then use to extend it on every page of your website. Create a `mysite/templates/mysite/base.html` file. You also need to create `templates` and `mysite` folders, but you probably have noticed this pattern already :) diff --git a/try_python/README.md b/try_python/README.md index 5e337552069..2b40825b43b 100644 --- a/try_python/README.md +++ b/try_python/README.md @@ -6,7 +6,7 @@ Let's write some code! ## Python prompt -To start tinkering with Python, we need to open up a *prompt* on your computer. On Mac OS X you can do this by launching `Terminal` application (It's in Applications → Utilities). On Windows you need to go to Start menu → All Programs → Accessories → Command Prompt. On Linux, it's probably under Applications → Accessories → Terminal. +To start tinkering with Python, we need to open up a *prompt* on your computer. On Mac OS X you can do this by launching the `Terminal` application (it's in Applications → Utilities). On Windows you need to go to Start menu → All Programs → Accessories → Command Prompt. On Linux, it's probably under Applications → Accessories → Terminal. A window should pop up on your screen. This window is a prompt, waiting for commands from you. We want to open up a Python console, so type in `python` and hit Enter. @@ -15,7 +15,7 @@ A window should pop up on your screen. This window is a prompt, waiting for comm Type "copyright", "credits" or "license" for more information. >>> -After running the python command, prompt changed to `>>>`. For us it means that for now we may use commands only in Python language. You don't have to type in `>>>` - Python will do that for you. +After running the python command, the prompt changed to `>>>`. For us it means that for now we may only use commands in the Python language. You don't have to type in `>>>` - Python will do that for you. ## Your first Python command! @@ -31,7 +31,7 @@ Nice! See how the answer popped out? Python knows math! You could try other comm Have fun with this for a little while and then get back here :) -As you can see, Python is a great calculator. If you're wonder what else you can do... +As you can see, Python is a great calculator. If you're wondering what else you can do... ## Strings @@ -40,14 +40,14 @@ Maybe your name? Type your first name in quotes like this: >>> "Ola" 'Ola' -You now created your first string! It's a set of characters that can be processed by a computer. The string must always begin and end with the same character. This may be an apostrophe (`'`) or double quotes (`"`) - they tell Python that it is a string. +You've now created your first string! It's a set of characters that can be processed by a computer. The string must always begin and end with the same character. This may be an apostrophe (`'`) or double quotes (`"`) - they tell Python that it is a string. Strings can be added. Try this: >>> "Hi there " + "Ola" 'Hi there Ola' -You can also multiply strings by number: +You can also multiply strings by a number: >>> "Ola" * 3 'OlaOlaOla' @@ -57,14 +57,14 @@ Nice, huh? To see your name in uppercase, simply type: >>> "Ola".upper() 'OLA' -You just used the `upper` __method__ on your string! Method (`upper`) is a set of instructions that Python has to perform on given object (`"Ola"`) once you call it. +You just used the `upper` __method__ on your string! A method (`upper`) is a set of instructions that Python has to perform on a given object (`"Ola"`) once you call it. -If you want to get a number of letters in your name, there is a method for that too! +If you want to get the number of letters in your name, there is a method for that too! >>> len("Ola") 3 -Wonder why sometimes you call methods by adding `.` at the end of the string (like `"Ola".upper()`) and sometimes you first call a method and place string in parentheses? Well, in some cases, methods belong to objects, like `upper` that can only be performed on Strings. But sometimes, methods don't belong to anything specific and can be used on different types of objects, just like `len`. That's why we're giving `"Ola"` as a parameter to `len` method. +Wonder why sometimes you call methods by adding `.` at the end of the string (like `"Ola".upper()`) and sometimes you first call a method and place the string in parentheses? Well, in some cases, methods belong to objects, like `upper` that can only be performed on Strings. But sometimes, methods don't belong to anything specific and can be used on different types of objects, just like `len`. That's why we're giving `"Ola"` as a parameter to `len` method. ### Summary @@ -85,7 +85,7 @@ Let's try something. Can we know the length of a number, the same way we learn a File "", line 1, in TypeError: object of type 'int' has no len() -We got our first error! It says that objects of type "int" (integers, whole numbers) doesn't have a length. So what can we do know? Maybe we can write our number as string? Strings have length, right? +We got our first error! It says that objects of type "int" (integers, whole numbers) don't have a length. So what can we do now? Maybe we can write our number as string? Strings have length, right? >>> len(str(304023)) 6 @@ -234,7 +234,7 @@ Awesome! Wanna do one more? Try this: >>> 3 > 2 or 2 < 1 True -You can give Python as many numbers to compare as you want, and he will give you an answer! Pretty smart, right? +You can give Python as many numbers to compare as you want, and it will give you an answer! Pretty smart, right? - __and__ - if you use `and` operator, both of the comparisons have to be True in order for the whole thing to be True - __or__ - if you use `or` operator, only one of the comparisons has to be True in order for the whole thing to be True @@ -288,7 +288,7 @@ So far nothing has happened, as evidenced by dots `...` instead of incentives `> ^ IndentationError: expected an indented block -Well...something went wrong. Python needs to know whether the instruction we have written is a continuation of if or it is the next instruction not covered by the condition. To this purpose we need to indent our code: +Well...something went wrong. Python needs to know whether the instruction we have written is a continuation of `if` or it is the next instruction not covered by the condition. To this purpose we need to indent our code: >>> if 3 > 2: ... print('It works!') @@ -345,12 +345,12 @@ Time for the last part of this chapter! Remember about methods like `len` that you can execute in Python? Well, good news, you will learn how to write you own functions now! -Function is a set of instructions that Python should execute. Each function in Python starts with the keyword `def`, has a name and can have some parameters. Let's start with easy one: +A function is a set of instructions that Python should execute. Each function in Python starts with the keyword `def`, has a name and can have some parameters. Let's start with an easy one: >>> def hi(): ... -As you can see, there are the dots again! This means that nothing really happen yet.. and yes, we need to do a `TAB` before giving our instructions: +As you can see, there are the dots again! This means that nothing has really happenned yet.. and yes, we need to do a `TAB` before giving our instructions: >>> def hi(): ... print('Hi there!') @@ -395,7 +395,7 @@ Awesome, right? This way you don't have to repeat yourself every time you want t Let's do something smarter -- there is more names than two, and writing a condition for each would be hard, right? >>> def hi(name): - ... print('Hi '+name+'!') + ... print('Hi ' + name + '!') ... Let's call the function now: