diff --git a/deploy/README.md b/deploy/README.md index 11c3d178cf8..850880474c7 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -91,7 +91,7 @@ Heroku uses git repository to manage your project files, so we need to use it to Create `.gitignore` file with following content: venv - *.pyc + __pycache__ staticfiles and save it. The dot on the begining of the name file is important! This will tell Heroku to ignore this file and don't use it. diff --git a/django_admin/README.md b/django_admin/README.md index ad3cf0afc08..0869bccf740 100644 --- a/django_admin/README.md +++ b/django_admin/README.md @@ -29,7 +29,7 @@ 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 the Django admin, you should check Django's 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/1.6/ref/contrib/admin/ 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 6b60f6d3e0b..a16edcce2ba 100644 --- a/django_forms/README.md +++ b/django_forms/README.md @@ -183,13 +183,13 @@ Basically we have two things here: we save the form with `form.save` and we add 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: from django.core.urlresolvers import reverse - from django.http import HttpResponseRedirect + from django.shortcuts import redirect Add them at the very beginning of your file. And now we can say: go to `post_detail` page for a post. - return HttpResponseRedirect(reverse(post_detail, kwargs={'pk': post.pk})) + return redirect('blog.views.post_detail', pk=post.pk) -`post_detail` is a name of the view we want to go to. Remember that this view required a `pk` variable? To pass it to the views we use `kwargs={'pk': post.pk}`, where post is newly created blog post! +`blog.views.post_detail` is a name of the view we want to go to. Remember that this view required a `pk` variable? To pass it to the views we use `pk=post.pk`, where post is newly created blog post! Ok, we talked a lot, but we probably would like to see how the whole view looks like, right? @@ -200,7 +200,7 @@ Ok, we talked a lot, but we probably would like to see how the whole view looks post = form.save(commit=False) post.author = request.user post.save() - return HttpResponseRedirect(reverse(post_detail, kwargs={'pk': post.pk})) + return redirect('blog.views.post_detail', pk=post.pk) else: form = PostForm() return render(request, 'blog/post_edit.html', {'form': form}) @@ -228,7 +228,6 @@ Open `blog/post_detail.html` and add this line: so that the template will look like: {% extends 'mysite/base.html' %} - {% load future %} {% block content %}
@@ -257,7 +256,7 @@ Let's open a `blog/views.py` and add at the very end of the file: post = form.save(commit=False) post.author = request.user post.save() - return HttpResponseRedirect(reverse(post_detail, kwargs={'pk': post.pk})) + return redirect('blog.views.post_detail', pk=post.pk) else: form = PostForm(instance=post) return render(request, 'blog/post_edit.html', {'form': form}) @@ -282,7 +281,7 @@ Feel free to change the title or the text and save changes! Congratulations! Your application is more and more complete! -If you need more information about Django forms you should read the documentation: https://docs.djangoproject.com/en/dev/topics/forms/ +If you need more information about Django forms you should read the documentation: https://docs.djangoproject.com/en/1.6/topics/forms/ We prepared some extra tasks for you, but they are not very hard. You can do them as a homework: - create a page with all __draft__ posts diff --git a/django_installation/README.md b/django_installation/README.md index d7ecb11bbb2..e296f6811c4 100644 --- a/django_installation/README.md +++ b/django_installation/README.md @@ -48,10 +48,10 @@ Ok, we have all important things in place. We can finally install Django! ## Installing Django -Now, when you have your `virtualenv` started, you can install Django using PIP. In console/command-line you type `pip install django==1.6.4`. +Now, when you have your `virtualenv` started, you can install Django using PIP. In console/command-line you type `pip install django==1.6.5`. - (blog) ~$ pip install django==1.6.4 - Downloading/unpacking django==1.6.4 + (blog) ~$ pip install django==1.6.5 + Downloading/unpacking django==1.6.5 Installing collected packages: django Successfully installed django Cleaning up... diff --git a/django_models/README.md b/django_models/README.md index a51b49287db..8b9067f90e4 100644 --- a/django_models/README.md +++ b/django_models/README.md @@ -105,7 +105,7 @@ Let's open `blog/models.py`, remove everything from it and write code like this: title = models.CharField(max_length=200) text = models.TextField() created_date = models.DateTimeField( - default=timezone.now()) + default=timezone.now) published_date = models.DateTimeField( blank=True, null=True) @@ -113,7 +113,7 @@ Let's open `blog/models.py`, remove everything from it and write code like this: self.published_date = timezone.now() self.save() - def __unicode__(self): + def __str__(self): return self.title It is scary, right? But no worries, we will explain what these lines mean! @@ -133,11 +133,11 @@ Now we define properties we where talking about: `title`, `text`, `created_date` - `models.DateTimeField` - this is a date - `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 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/1.6/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 average price you could call it `calculate_average_price`). -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. +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 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! diff --git a/django_orm_querysets/README.md b/django_orm_querysets/README.md index c289468ba57..4d6913ea53c 100644 --- a/django_orm_querysets/README.md +++ b/django_orm_querysets/README.md @@ -65,7 +65,7 @@ So finally our `views.py` file should look like this: That's it! Time to go back to our template and display this queryset! -If you want to read a little bit more about querysets in Django you should look here: https://docs.djangoproject.com/en/dev/ref/models/querysets/ +If you want to read a little bit more about querysets in Django you should look here: https://docs.djangoproject.com/en/1.6/ref/models/querysets/ diff --git a/domain/README.md b/domain/README.md index 467c49fd523..7c61f1a2ead 100644 --- a/domain/README.md +++ b/domain/README.md @@ -6,7 +6,7 @@ In this chapter we will teach you how to buy a domain and direct it to Heroku! ## Where to register a domain? -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. +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.com/search?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 wanted to support Django Girls and they gave us a 20% discount code for you! :) Ask organizers or coaches for it! diff --git a/extend_your_application/README.md b/extend_your_application/README.md index f206ebe8c6a..15770c86243 100644 --- a/extend_your_application/README.md +++ b/extend_your_application/README.md @@ -123,7 +123,6 @@ We will create a file in `blog/template/blog` called `post_detail.html`. It will look like this: {% extends 'mysite/base.html' %} - {% load future %} {% block content %}
diff --git a/homework_add_more_to_your_website/README.md b/homework_add_more_to_your_website/README.md index 6ed5082ffc8..ca27ee122f8 100644 --- a/homework_add_more_to_your_website/README.md +++ b/homework_add_more_to_your_website/README.md @@ -27,7 +27,6 @@ This line `Post.objects.filter(published_date__isnull=True).order_by('created_da Ok, the last bit is of course a template! Create a file `blog/templates/blog/post_draft_list.html` and add the following: {% extends 'mysite/base.html' %} - {% load future %} {% block content %} {% for post in posts %} @@ -74,7 +73,7 @@ and finally, a view (as always, in `blog/views.py`): def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) post.publish() - return HttpResponseRedirect(reverse(post_detail, kwargs={'pk': pk})) + return redirect('blog.views.post_detail', pk=pk) Remember, when we created a `Post` model we wrote a method `publish`. It looked like this: @@ -107,11 +106,11 @@ Now, time for a view! Open `blog/views.py` and add this code: def post_remove(request, pk): post = get_object_or_404(Post, pk=pk) post.delete() - return HttpResponseRedirect(reverse(post_list)) + return redirect('blog.views.post_list') 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`. +And this time, after deleting a post we want to go to the webpage with a list of posts, so we are using `redirect`. Let's test it! Go to the page with a post and try to delete it! diff --git a/install_python/README.md b/install_python/README.md index a7f066be2b0..6f794042d2a 100644 --- a/install_python/README.md +++ b/install_python/README.md @@ -14,14 +14,14 @@ 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 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. +You can download Python for Windows from the website https://www.python.org/download/releases/3.4.1/. 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 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 + Python 3.4.1 If you don't have Python installed or you want a different version, you can install it as follows. @@ -40,7 +40,7 @@ Yout type in the console: ### OS X -You need to go to the website https://www.python.org/downloads/release/python-340/ and install the appropriate package for you operating system. +You need to go to the website https://www.python.org/downloads/release/python-341/ and install the appropriate package for you operating system. ---- diff --git a/try_python/README.md b/try_python/README.md index 2b40825b43b..ff7c3c93ce4 100644 --- a/try_python/README.md +++ b/try_python/README.md @@ -11,7 +11,7 @@ To start tinkering with Python, we need to open up a *prompt* on your computer. 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. (workshops) ~$ python - Python 3.4.0 (...) + Python 3.4.1 (...) Type "copyright", "credits" or "license" for more information. >>> @@ -182,7 +182,7 @@ If you want to only read the first number, you can do this by using index. The f As you can see, you can access different objects in your list by using its name and index number inside of brackets. -You can find a list of all available list methods here in Python documentation: https://docs.python.org/2/tutorial/datastructures.html +You can find a list of all available list methods here in Python documentation: https://docs.python.org/3/tutorial/datastructures.html ### Summary