Skip to content

Commit

Permalink
Merge branch 'master' of github.com:DjangoGirls/tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
aniav committed Apr 2, 2015
2 parents d58f8b5 + fda4abc commit ac645a7
Show file tree
Hide file tree
Showing 52 changed files with 145 additions and 118 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Django Girls Tutorial
# Django Girls Tutorial
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/DjangoGirls/tutorial?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

> This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
Expand Down
29 changes: 28 additions & 1 deletion en/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,15 @@ Create a file named `.gitignore` in your `djangogirls` directory with the follow
staticfiles
local_settings.py
db.sqlite3
*.py[co]

and save it. The dot on the beginning of the file name is important! As you can see, we're now telling Heroku to ignore `local_settings.py` and don't download it, so it's only available on your computer (locally).

Next, we’ll create a new git repository and save our changes. Go to your console and run these commands:
Next, we’ll create a new git repository and save our changes.

> __Note__: Check out your current working directory with a `pwd` command before initializing the repository. You should be in the `djangogirls` folder.
Go to your console and run these commands:

$ git init
Initialized empty Git repository in ~/djangogirls/.git/
Expand All @@ -141,6 +146,28 @@ Next, we’ll create a new git repository and save our changes. Go to your conso

Initializing the git repository is something we only need to do once per project.

It's a good idea to use a `git status` command before `git add` or whenever you find yourself unsure of what will be done, to prevent any surprises from happening (e.g. wrong files will be added or commited). The `git status` command returns information about any untracked/modifed/staged files, branch status and much more. The output should be similar to:

$ git status
On branch master

Initial commit

Untracked files:
(use "git add <file>..." to include in what will be committed)

.gitignore
Procfile
mysite/__init__.py
mysite/settings.py
mysite/urls.py
mysite/wsgi.py
manage.py
requirements.txt
runtime.txt

nothing added to commit but untracked files present (use "git add" to track)

And finally we save our changes. Go to your console and run these commands:

$ git add -A .
Expand Down
2 changes: 1 addition & 1 deletion en/django_admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Make sure that at least two or three posts (but not all) have the publish date s

![Django admin](images/edit_post3.png)

If you want to know more about Django admin, you should check Django's documentation: https://docs.djangoproject.com/en/1.7/ref/contrib/admin/
If you want to know more about Django admin, you should check Django's documentation: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/

This is probably a good moment to grab a coffee (or tea) or something to eat to re-energise yourself. You created your first Django model - you deserve a little timeout!

Expand Down
8 changes: 4 additions & 4 deletions en/django_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ We open `blog/urls.py` and add a line:

And the final code will look like this:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from . import views

urlpatterns = patterns('',
urlpatterns = [
url(r'^$', views.post_list),
url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),
url(r'^post/new/$', views.post_new, name='post_new'),
)
]

After refreshing the site, we see an `AttributeError`, since we don't have `post_new` view implemented. Let's add it right now.

Expand Down Expand Up @@ -282,7 +282,7 @@ Feel free to change the title or the text and save changes!

Congratulations! Your application is getting more and more complete!

If you need more information about Django forms you should read the documentation: https://docs.djangoproject.com/en/1.7/topics/forms/
If you need more information about Django forms you should read the documentation: https://docs.djangoproject.com/en/1.8/topics/forms/

## One more thing: deploy time!

Expand Down
10 changes: 5 additions & 5 deletions en/django_installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To create a new `virtualenv`, you need to open the console (we told you about th

C:\Users\Name\djangogirls> C:\Python34\python -m venv myvenv

where `C:\Python34\python` is the directory in which you previously installed Python and `myvenv` is the name of your `virtualenv`. You can use any other name, but stick to lowercase and use no spaces. It is also good idea to keep the name short - you'll be referencing it a lot!
where `C:\Python34\python` is the directory in which you previously installed Python and `myvenv` is the name of your `virtualenv`. You can use any other name, but stick to lowercase and use no spaces, accents or special characters. It is also good idea to keep the name short - you'll be referencing it a lot!

### Linux and OS X

Expand Down Expand Up @@ -88,16 +88,16 @@ OK, we have all important dependencies in place. We can finally install Django!

## Installing Django

Now that you have your `virtualenv` started, you can install Django using `pip`. In the console, run `pip install django==1.7.7` (note that we use a double equal sign: `==`).
Now that you have your `virtualenv` started, you can install Django using `pip`. In the console, run `pip install django==1.8` (note that we use a double equal sign: `==`).

(myvenv) ~$ pip install django==1.7.7
Downloading/unpacking django==1.7.7
(myvenv) ~$ pip install django==1.8
Downloading/unpacking django==1.8
Installing collected packages: django
Successfully installed django
Cleaning up...

on Windows
> If you get an error when calling pip on Windows platform please check if your project pathname contains spaces (i.e. `C:\Users\User Name\djangogirls`). If it does please consider moving it to another place without spaces (suggestion is: `C:\djangogirls`). After the move please try the above command again.
> If you get an error when calling pip on Windows platform please check if your project pathname contains spaces, accents or special characters (i.e. `C:\Users\User Name\djangogirls`). If it does please consider moving it to another place without spaces, accents or special characters (suggestion is: `C:\djangogirls`). After the move please try the above command again.
on Linux
> If you get an error when calling pip on Ubuntu 12.04 please run `python -m pip install -U --force-reinstall pip` to fix the pip installation in the virtualenv.
Expand Down
2 changes: 1 addition & 1 deletion en/django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Now we define properties we were talking about: `title`, `text`, `created_date`,
- `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.7/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`).

Expand Down
20 changes: 10 additions & 10 deletions en/django_urls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Every page on the Internet needs its own URL. This way your application knows wh

Let's open up the `mysite/urls.py` file and see what it looks like:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = patterns('',
urlpatterns = [
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
]

As you can see, Django already put something here for us.

Expand Down Expand Up @@ -52,30 +52,30 @@ Go ahead, delete the commented lines (lines starting with `#`) and add a line th

Your `mysite/urls.py` file should now look like this:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = patterns('',
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('blog.urls')),
)
]

Django will now redirect everything that comes into 'http://127.0.0.1:8000/' to `blog.urls` and look for further instructions there.

## blog.urls

Create a new `blog/urls.py` empty file. All right! Add these two first lines:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from . import views

Here we're just importing Django's methods and all of our `views` from `blog` application (we don't have any yet, but we will get to that in a minute!)

After that, we can add our first URL pattern:

urlpatterns = patterns('',
urlpatterns = [
url(r'^$', views.post_list),
)
]

As you can see, we're now assigning a `view` called `post_list` to `^$` URL. But what does `^$` mean? It's a regex magic :) Let's break it down:
- `^` in regex means "the beginning"; from this sign we can start looking for our pattern
Expand All @@ -91,4 +91,4 @@ There is no "It works" anymore, huh? Don't worry, it's just an error page, nothi

You can read that there is __no attribute 'post_list'__. Is *post_list* reminding you of anything? This is how we called our view! This means that everything is in place, we just didn't create our *view* yet. No worries, we will get there.

> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/1.7/topics/http/urls/
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/1.8/topics/http/urls/
2 changes: 1 addition & 1 deletion en/django_views/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Another error! Read what's going on now:

This one is easy: *TemplateDoesNotExist*. Let's fix this bug and create a template in the next chapter!

> Learn more about Django views by reading the official documentation: https://docs.djangoproject.com/en/1.7/topics/http/views/
> Learn more about Django views by reading the official documentation: https://docs.djangoproject.com/en/1.8/topics/http/views/
2 changes: 1 addition & 1 deletion en/dynamic_data_in_templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ So finally our `blog/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/1.7/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.8/ref/models/querysets/



Expand Down
6 changes: 3 additions & 3 deletions en/extend_your_application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Let's create a URL in `urls.py` for our `post_detail` *view*!

We 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<pk>[0-9]+)/$', views.post_detail),` to the `blog/urls.py` file. It should look like this:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from . import views

urlpatterns = patterns('',
urlpatterns = [
url(r'^$', views.post_list),
url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),
)
]

That one looks scary, but no worries - we will explain it for you:
- it starts with `^` again -- "the beginning"
Expand Down
8 changes: 4 additions & 4 deletions en/html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A Django template's format is described in a language called HTML (that's the HT

HTML is a simple code that is interpreted by your web browser - such as Chrome, Firefox or Safari - to display a webpage for the user.

HTML stands for "HyperText Markup Language." __HyperText__ means it's a type of text that supports hyperlinks between pages. __Markup__ means we have taken a document and marked it up with code to tell something (in this case, a browser) how to interpret the page. HTML code is built with __tags__, each one starting with `<` and ending with `>`. These tags markup __elements__.
HTML stands for "HyperText Markup Language". __HyperText__ means it's a type of text that supports hyperlinks between pages. __Markup__ means we have taken a document and marked it up with code to tell something (in this case, a browser) how to interpret the page. HTML code is built with __tags__, each one starting with `<` and ending with `>`. These tags markup __elements__.

## Your first template!

Expand All @@ -28,7 +28,7 @@ And now create a `post_list.html` file (just leave it blank for now) inside the

See how your website looks now: http://127.0.0.1:8000/

> If you still have an error `TemplateDoesNotExists`, try to restart your server. Go into command line, stop the reserver by pressing Ctrl+C (Control and C buttons together) and start it again by running a `python manage.py runserver` command.
> If you still have an error `TemplateDoesNotExists`, try to restart your server. Go into command line, stop the server by pressing Ctrl+C (Control and C buttons together) and start it again by running a `python manage.py runserver` command.
![Figure 11.1](images/step1.png)

Expand Down Expand Up @@ -125,7 +125,7 @@ Here's an example of a full template:

We've created three `div` sections here.

- The first `div` element contains the title of our blogpost - it's a heading and a link
- The first `div` element contains the title of our blog - it's a heading and a link
- Another two `div` elements contain our blogposts with a published date, `h2` with a post title that is clickable and two `p`s (paragraph) of text, one for the date and one for our blogpost.

It gives us this effect:
Expand All @@ -134,7 +134,7 @@ It gives us this effect:

Yaaay! But so far, our template only ever displays exactly __the same information__ - whereas earlier we were talking about templates as allowing us to display __different__ information in the __same format__.

What we want really want to do is display real posts added in our Django admin - and that's where we're going next.
What we really want to do is display real posts added in our Django admin - and that's where we're going next.

## One more thing

Expand Down
2 changes: 1 addition & 1 deletion en/whats_next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ After that make sure to:
Yes! First, go ahead and try our other book, called [Django Girls Tutorial: Extensions](http://djangogirls.gitbooks.io/django-girls-tutorial-extensions/).

Later on, you can try recources listed below. They're all very recommended!
- [Django's official tutorial](https://docs.djangoproject.com/en/1.7/intro/tutorial01/)
- [Django's official tutorial](https://docs.djangoproject.com/en/1.8/intro/tutorial01/)
- [New Coder tutorials](http://newcoder.io/tutorials/)
- [Code Academy Python course](http://www.codecademy.com/en/tracks/python)
- [Code Academy HTML & CSS course](http://www.codecademy.com/tracks/web)
Expand Down
4 changes: 2 additions & 2 deletions es/deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Crea un fichero llamado `.gitignore` en tu directorio `djangogirls` con el sigui
staticfiles
local_settings.py
db.sqlite3

*.py[co]

y guarda los cambios. El punto al principio del nombre del fichero es importante! Como puedes ver, ahora le estamos diciendo a Heroku que ignore el fichero `local_settings.py` y no lo descargue, para que esté disponible solamente en tu ordenador (en local).

Expand Down Expand Up @@ -234,4 +234,4 @@ El error que veías era debido a que cuando desplegamos en Heroku creamos una nu
$ heroku run python manage.py createsuperuser


Ahora deberías poder acceder a tu sitio web desde el navegador! Felicidades :)!
Ahora deberías poder acceder a tu sitio web desde el navegador! Felicidades :)!
4 changes: 2 additions & 2 deletions es/django_admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ Asegúrate que al menos dos o tres entradas (pero no todas) tengan la fecha de p

[3]: images/edit_post3.png

Sí quieres sabes más sobre Django admin, deberías revisar la documentación de Django: https://docs.djangoproject.com/en/1.7/ref/contrib/admin/
Sí quieres sabes más sobre Django admin, deberías revisar la documentación de Django: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/

Probablemente sea un buen momento para tomar un café (o té) y comer algo dulce. Haz creado tu primer modelo Django - te mereces un regalito!
Probablemente sea un buen momento para tomar un café (o té) y comer algo dulce. Haz creado tu primer modelo Django - te mereces un regalito!
10 changes: 5 additions & 5 deletions es/django_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ Abrimos el `blog/urls.py` y añadimos una línea:

Y el código final tendrá este aspecto:

from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from . import views

urlpatterns = patterns('',
urlpatterns = [
url(r'^$', views.post_list),
url(r'^post/(?P<pk>[0-9]+)/$', views.post_detail),
url(r'^post/new/$', views.post_new, name='post_new'),
)
]


Después de actualizar el sitio, veremos un `AttributeError`, puesto que no tenemos la vista `post_new` implementado. Vamos a añadir ahora.
Expand Down Expand Up @@ -315,7 +315,7 @@ Al dar click ahí, debes ver el formulario con nuestro post del blog:

¡Felicitaciones.Tu aplicación está cada vez más completa!

Si necesitas más información sobre los formularios de Django, debes leer la documentación: https://docs.djangoproject.com/en/1.7/topics/forms/
Si necesitas más información sobre los formularios de Django, debes leer la documentación: https://docs.djangoproject.com/en/1.8/topics/forms/

## Una cosa más: ¡Tiempo de implementación!

Expand All @@ -331,4 +331,4 @@ Sería bueno ver si tu sitio sigue funcionando en Heroku, ¿no? Intentemos imple
$ git push heroku master


¡Y eso debería ser todo! Felicidades :)
¡Y eso debería ser todo! Felicidades :)
8 changes: 4 additions & 4 deletions es/django_installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ Tenemos todas las dependencias importantes en su lugar. ¡Finalmente podemos ins

## Instalar Django

Ahora que tienes tu `virtualenv` iniciado, puedes instalar Django usando `pip`. En la consola, ejecuta `pip install django == 1.7.1` (fíjate que utilizamos un doble signo igual): `==`).
Ahora que tienes tu `virtualenv` iniciado, puedes instalar Django usando `pip`. En la consola, ejecuta `pip install django == 1.8` (fíjate que utilizamos un doble signo igual): `==`).

(myvenv) ~$ pip install django==1.7.1
Downloading/unpacking django==1.7.1
(myvenv) ~$ pip install django==1.8
Downloading/unpacking django==1.8
Installing collected packages: django
Successfully installed django
Cleaning up...
Expand All @@ -110,4 +110,4 @@ en Linux

> Si obtienes un error al correr pip en Ubuntu 12.04 ejecuta `python -m pip install- U - force-resintall pip` para arreglar la instalación de pip en el virtualenv.
¡Eso es todo. Ahora estás listo (por fin) para crear una aplicación Django! Pero para hacer eso, necesitas un buen programa en el cual escribir código...
¡Eso es todo. Ahora estás listo (por fin) para crear una aplicación Django! Pero para hacer eso, necesitas un buen programa en el cual escribir código...
Loading

0 comments on commit ac645a7

Please sign in to comment.