You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> The period `.` is crucial because it tells the script to install Django in your current directory (for which the period `.` is a short-hand reference)
28
32
@@ -32,13 +36,15 @@ of the prompt that will be inviting your input on your command line.
32
36
33
37
`django-admin.py` is a script that will create the directories and files for you. You should now have a directory structure which looks like this:
34
38
35
-
djangogirls
36
-
├───manage.py
37
-
└───mysite
38
-
settings.py
39
-
urls.py
40
-
wsgi.py
41
-
__init__.py
39
+
```:command-line
40
+
djangogirls
41
+
├───manage.py
42
+
└───mysite
43
+
settings.py
44
+
urls.py
45
+
wsgi.py
46
+
__init__.py
47
+
```
42
48
43
49
44
50
`manage.py` is a script that helps with management of the site. With it we will be able to start a web server on our computer without installing anything else, amongst other things.
@@ -58,7 +64,7 @@ It would be nice to have the correct time on our website. Go to the [wikipedia t
58
64
59
65
In settings.py, find the line that contains `TIME_ZONE` and modify it to choose your own timezone:
60
66
61
-
```python
67
+
```python:settings.py
62
68
TIME_ZONE='Europe/Berlin'
63
69
```
64
70
@@ -67,7 +73,7 @@ Modifying "Europe/Berlin" as appropriate
67
73
68
74
We'll also need to add a path for static files (we'll find out all about static files and CSS later in the tutorial). Go down to the *end* of the file, and just underneath the `STATIC_URL` entry, add a new one called `STATIC_ROOT`:
69
75
70
-
```python
76
+
```python:settings.py
71
77
STATIC_URL='/static/'
72
78
STATIC_ROOT= os.path.join(BASE_DIR, 'static')
73
79
```
@@ -79,7 +85,7 @@ There's a lot of different database software that can store data for your site.
79
85
80
86
This is already set up in this part of your `mysite/settings.py` file:
81
87
82
-
```python
88
+
```python:settings.py
83
89
DATABASES= {
84
90
'default': {
85
91
'ENGINE': 'django.db.backends.sqlite3',
@@ -90,41 +96,50 @@ DATABASES = {
90
96
91
97
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:
Apply all migrations: contenttypes, sessions, admin, auth
104
+
Synchronizing apps without migrations:
105
+
Creating tables...
106
+
Running deferred SQL...
107
+
Installing custom SQL...
108
+
Running migrations:
109
+
Rendering model states... DONE
110
+
Applying contenttypes.0001_initial... OK
111
+
Applying auth.0001_initial... OK
112
+
Applying admin.0001_initial... OK
113
+
Applying contenttypes.0002_remove_content_type_name... OK
114
+
Applying auth.0002_alter_permission_name_max_length... OK
115
+
Applying auth.0003_alter_user_email_max_length... OK
116
+
Applying auth.0004_alter_user_username_opts... OK
117
+
Applying auth.0005_alter_user_last_login_null... OK
118
+
Applying auth.0006_require_contenttypes_0002... OK
119
+
Applying sessions.0001_initial... OK
120
+
```
121
+
113
122
114
123
And we're done! Time to start the web server and see if our website is working!
115
124
116
125
You need to be in the directory that contains the `manage.py` file (the `djangogirls` directory). In the console, we can start the web server by running `python manage.py runserver`:
Now all you need to do is check that your website is running. Open your browser (Firefox, Chrome, Safari, Internet Explorer or whatever you use) and enter the address:
126
139
127
-
http://127.0.0.1:8000/
140
+
```:browser
141
+
http://127.0.0.1:8000/
142
+
```
128
143
129
144
The web server will take over your command prompt until you stop it. To type more commands whilst it is running open a new terminal window and activate your virtualenv. To stop the web server, switch back to the window in which it's running and pressing CTRL+C - Control and C buttons together (on Windows, you might have to press Ctrl+Break).
0 commit comments