Skip to content

Commit

Permalink
Upgrade to Django 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBlack85 authored and olasitarska committed Sep 25, 2014
1 parent 72f2143 commit d8ba815
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
13 changes: 11 additions & 2 deletions django_admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ You will see a login page like this:

![Login page](images/login_page2.png)

You should use the username and password you chose when you were creating a database (in the __Starting Django project__ chapter). After logging in, you should see the Django admin dashboard.
In order to log in you need to create a *superuser* - a user which has control over everything on the site. Go back to you command-line and type `python manage.py createsuperuser`, press enter and type your username (lowercase, no spaces), email address and password when you're asked for them. The output should look like this (where username and email should be your own ones):

(myvenv) ~/djangogirls$ python manage.py createsuperuser
Username: admin
Email address: admin@admin.com
Password:
Password (again):
Superuser created successfully.

Return to your browser and log in with the superuser's credentials you chose, you should see the Django admin dashboard.

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

Expand All @@ -29,7 +38,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.6/ref/contrib/admin/
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/

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!

Expand Down
2 changes: 1 addition & 1 deletion django_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,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.6/topics/forms/
If you need more information about Django forms you should read the documentation: https://docs.djangoproject.com/en/1.7/topics/forms/

## One more thing: deploy time!

Expand Down
6 changes: 3 additions & 3 deletions django_installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ 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.6.6` (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.7` (note that we use a double equal sign: `==`).

(myvenv) ~$ pip install django==1.6.6
Downloading/unpacking django==1.6.6
(myvenv) ~$ pip install django==1.7
Downloading/unpacking django==1.7
Installing collected packages: django
Successfully installed django
Cleaning up...
Expand Down
36 changes: 22 additions & 14 deletions django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ You will notice that a new `blog` directory is created and it contains a number
| wsgi.py
├── manage.py
└── blog
__init__.py
admin.py
models.py
tests.py
views.py
├── migrations
| __init__.py
├── __init__.py
├── admin.py
├── models.py
├── tests.py
└── views.py

After creating an application we also need to tell Django that it should use it. We do that in the file `mysite/settings.py`. We need to find `INSTALLED_APPS` and add a line containing `'blog',` just above `)`. So the final product should look like this:

Expand Down Expand Up @@ -134,7 +136,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.6/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.7/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 All @@ -144,13 +146,19 @@ If something is still not clear about models, feel free to ask your coach! We kn

### Create tables for models in your database

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

(myvenv) ~/djangogirls$ python manage.py syncdb
Creating tables ...
Creating table blog_post
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
(myvenv) ~/djangogirls$ python manage.py makemigrations blog
Migrations for 'blog':
0001_initial.py:
- Create model Post

It would be nice to see this Post model, right? Jump to the next chapter to see what your Post looks like!
Django prepared for us a migration file that we have to apply now to our database, type `python manage.py migrate blog`, the output should be:

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

Hurray! Our Post model is now in our database, it would be nice to see it, right? Jump to the next chapter to see what your Post looks like!
36 changes: 10 additions & 26 deletions django_start_project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,16 @@ This is already set up in this part of your `mysite/settings.py` file:
}
}

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

(myvenv) ~/djangogirls$ python manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'Name'):
Email address: admin@example.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

It will ask you if you want to create a *superuser* - a user which has control over everything on the site. Type `yes`, press enter and type your username (lowercase, no spaces), email address and password when you're asked for them. Remember this username and password! We'll use it later.
To create a database for our blog, let's run the following in the console: `python manage.py migrate` (we need to be in the `djangogirls` directory that contains the `manage.py` file). If that goes well, you should see something like this:

(myvenv) ~/djangogirls$ python manage.py migrate
Operations to perform:
Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK

And we're done! Time to start the web server and see if our website is working!

Expand Down
2 changes: 1 addition & 1 deletion django_urls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ 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.6/topics/http/urls/
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/1.7/topics/http/urls/
2 changes: 1 addition & 1 deletion 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.6/topics/http/views/
> Learn more about Django views by reading the official documentation: https://docs.djangoproject.com/en/1.7/topics/http/views/
2 changes: 1 addition & 1 deletion dynamic_data_in_templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,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.6/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.7/ref/models/querysets/



Expand Down
5 changes: 2 additions & 3 deletions whats_next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ 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 highly recommended!
- [Django's official tutorial](https://docs.djangoproject.com/en/1.6/intro/tutorial01/)
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/)
- [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)
- [Django Carrots tutorial](http://django.carrots.pl/en/)
- [Learn Python The Hard Way book](http://learnpythonthehardway.org/book/)
- [Getting Started With Django video lessons](http://gettingstartedwithdjango.com/)
- [Two Scoops of Django: Best Practices for Django](http://twoscoopspress.org/products/two-scoops-of-django-1-6) book

0 comments on commit d8ba815

Please sign in to comment.