|
4 | 4 |
|
5 | 5 | ## Virtual environment |
6 | 6 |
|
7 | | -Before we will install Django, we will make you install something very, very handy and useful, that will help you 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! |
| 7 | +Before we install Django, we'll get you to install an extremely useful tool that will help keep your coding environment tidy on your computer. It's possible to skip this step, but it's highly recommended not to - starting with the best possible setup will save you a lot of trouble in the future! |
8 | 8 |
|
9 | | -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? |
| 9 | +So, let's create a **virtual environment** (also called a *virtualenv*). It will isolate your Python/Django setup on a per-project basis, meaning that any changes you make to one website won't affect any others you're also developing. Neat, right? |
10 | 10 |
|
11 | | -All you need to do is finding a folder in which you want to create the `virtualenv`, for example your home directory. In Windows it could look like: `C:\Users\Name\` (where `Name` is a name of the user). |
| 11 | +All you need to do is find a folder in which you want to create the `virtualenv`; your home directory, for example. On Windows it might look like `C:\Users\Name\` (where `Name` is the name of your login). |
12 | 12 |
|
13 | 13 | ### Windows |
14 | 14 |
|
15 | | -To create a new `virtualenv` you need to open the console (we already told you how to open it, remember?) and type there `C:\Python\python -m venv blog`. It will look like this: |
| 15 | +To create a new `virtualenv`, you need to open the console (we told you about that a few tutorials ago - remember?) and run `C:\Python\python -m venv blog`. It will look like this: |
16 | 16 |
|
17 | 17 | C:\Users\Name> C:\Python34\python -m venv blog |
18 | 18 |
|
19 | | -where `C:\Python34\python` is folder in which you previously installed Python and `blog` is a 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 :). |
| 19 | +where `C:\Python34\python` is the folder in which you previously installed Python and `blog` is a 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! |
20 | 20 |
|
21 | 21 | ### Linux and OS X |
22 | 22 |
|
23 | | -Creating `virtualenv` in both Linux and OS X is as simple as typing in console (remember, that we expect that you have python 3.4 installed): |
| 23 | +Creating a `virtualenv` on both Linux and OS X is as simple as running: |
24 | 24 |
|
25 | 25 | ~$ python3 -m venv blog |
26 | 26 |
|
27 | | -### Working with virtualenv |
| 27 | +## Working with virtualenv |
28 | 28 |
|
29 | | -The command above will create a folder `blog` that contains our virtual environment (basically bunch of folders and files). All we want to do now is starting it by: |
| 29 | +The command above will create a folder called `blog` that contains our virtual environment (basically bunch of folders and files). All we want to do now is starting it by running: |
30 | 30 |
|
31 | 31 | C:\Users\Name> blog\Scripts\activate |
32 | 32 |
|
33 | | -for Windows users, or: |
| 33 | +on Windows, or: |
34 | 34 |
|
35 | 35 | ~$ source blog/bin/activate |
36 | 36 |
|
37 | | -for OS X and Linux. |
| 37 | +on OS X and Linux. |
38 | 38 |
|
39 | 39 | You will know that you have `virtualenv` started when you see that the prompt in your console looks like: |
40 | 40 |
|
|
44 | 44 |
|
45 | 45 | (blog) ~$ |
46 | 46 |
|
47 | | -so the prefix `(blog)` appears! |
| 47 | +Notice the prefix `(blog)` appears! |
48 | 48 |
|
49 | 49 | When working within a virtual environment, `python` will automatically refer to the correct version so you can use `python` instead of `python3`. |
50 | 50 |
|
51 | | -Ok, we have all important things in place. We can finally install Django! |
| 51 | +OK, we have all important dependencies in place. We can finally install Django! |
52 | 52 |
|
53 | 53 | ## Installing Django |
54 | 54 |
|
55 | | -Now, when you have your `virtualenv` started, you can install Django using PIP. In console you type `pip install django==1.6.5`. |
| 55 | +Now that you have your `virtualenv` started, you can install Django using `pip`. In the console, run `pip install django==1.6.5`. |
56 | 56 |
|
57 | 57 | (blog) ~$ pip install django==1.6.5 |
58 | 58 | Downloading/unpacking django==1.6.5 |
59 | 59 | Installing collected packages: django |
60 | 60 | Successfully installed django |
61 | 61 | Cleaning up... |
62 | 62 |
|
63 | | -### Installing PostgreSQL package for Python |
| 63 | +## Installing PostgreSQL package for Python |
| 64 | + |
| 65 | +Next up, we need to install a package which lets Python talk to PostgreSQL - this is called `psycopg2`. The installation instructions differ slightly between Windows and Linux/OS X. |
| 66 | + |
| 67 | +### Windows |
| 68 | + |
| 69 | +The installation steps vary slightly depending on whether your computer runs 32 or 64 bit Windows. If you're not sure which you're running, ask your coach. |
| 70 | + |
| 71 | +#### 32-bit |
| 72 | + |
| 73 | +Run the following in your console: |
| 74 | + |
| 75 | + (blog) C:\Users\Name> pip install git+https://github.com/nwcell/psycopg2-windows.git@win32-py34#egg=psycopg2 |
| 76 | + |
| 77 | +#### 64-bit |
| 78 | + |
| 79 | +Run the following in your console: |
| 80 | + |
| 81 | + (blog) C:\Users\Name> pip install git+https://github.com/nwcell/psycopg2-windows.git@win64-py34#egg=psycopg2 |
| 82 | + |
| 83 | +### Linux and OS X |
| 84 | + |
| 85 | +Run the following in your console: |
64 | 86 |
|
65 | 87 | (blog) ~$ pip install psycopg2 |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +If that goes well, you'll see something like this |
| 92 | + |
66 | 93 | Downloading/unpacking psycopg2 |
67 | 94 | Installing collected packages: psycopg2 |
68 | 95 | Successfully installed psycopg2 |
69 | 96 | Cleaning up... |
70 | 97 |
|
71 | | -On Windows, you will probably have to replace the first line with |
72 | | -`pip install git+https://github.com/nwcell/psycopg2-windows.git@win32-py34#egg=psycopg2` |
73 | | -or |
74 | | -`pip install git+https://github.com/nwcell/psycopg2-windows.git@win64-py34#egg=psycopg2` |
75 | | -depending on whether you have 32 or 64 bit Windows. |
76 | | - |
77 | | -Once it's completed execute `python -c "import psycopg2"`. If you get no errors, everything works. |
| 98 | +Once that's completed, run `python -c "import psycopg2"`. If you get no errors, everything's installed successfully. |
78 | 99 |
|
79 | | -That's it! Now you are finally ready to create a Django application! But to do that, you need some nice program to edit the code... |
| 100 | +That's it! You're now (finally) ready to create a Django application! But to do that, you need a nice program to write your code in... |
0 commit comments