Skip to content

Commit 537badb

Browse files
committed
capitalise Django, tweak INSTALLED_APPS listing, other minor changes.
by: Harry
1 parent 1a39a62 commit 537badb

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

content/django.txt

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
=================================================================================
2-
Creating a new django project on Python Anywhere
2+
Creating a new Django project on Python Anywhere
33
=================================================================================
44

55
So you want to create a web application but you don't really want to do all the
66
faffing around that is involved in setting up and configuring web servers?
77

88
Well that is one of the reasons we created Python Anywhere. This tutorial will
9-
take you through the process of creating a working django site with an admin
9+
take you through the process of creating a working Django site with an admin
1010
interface and a front page that tells you the time.
1111

12-
To follow along with this tutorial you will need a `Python Anywhere <http://www.pythonanywhere.com/>`_
12+
To follow along with this tutorial you will need a
13+
`Python Anywhere <http://www.pythonanywhere.com/>`_
1314
account. Go and sign up if you don't already have one then come back here.
1415

1516
.. contents:: Table of Contents
@@ -19,13 +20,12 @@ account. Go and sign up if you don't already have one then come back here.
1920

2021

2122

22-
2323
The really quick start guide
2424
=================================================================================
2525

2626
To start with, for those people who are already very confident with Django we will
2727
just start with a list of the steps and commands you need to run in order to get
28-
a working django app on PythonAnywhere. Don't worry if you don't understand these
28+
a working Django app on PythonAnywhere. Don't worry if you don't understand these
2929
now. We will go through each one, step by step, further down.
3030

3131
So, the really quick start guide:
@@ -56,7 +56,7 @@ so that it matches the value you entered above.
5656
import os
5757
import sys
5858

59-
## assuming your django settings file is at '/home/<my name>/<my project name>/settings.py'
59+
## assuming your Django settings file is at '/home/<my name>/<my project name>/settings.py'
6060
path = '/home/<my name>/'
6161
if path not in sys.path:
6262
sys.path.append(path)
@@ -66,7 +66,7 @@ so that it matches the value you entered above.
6666
import django.core.handlers.wsgi
6767
application = django.core.handlers.wsgi.WSGIHandler()
6868

69-
You should now have a default django app which you can visit at <my name>.pythonanywhere.com
69+
You should now have a default Django app which you can visit at <my name>.pythonanywhere.com
7070

7171
Edit settings.py
7272
---------------------------------------------------------------------------------
@@ -79,15 +79,16 @@ database and installed apps sections to match the code below.
7979
DATABASES = {
8080
'default': {
8181
'ENGINE': 'django.db.backends.sqlite3',
82-
'NAME': '/home/%s/my_test_project/db.sqlite',
82+
'NAME': '/home/<my name>/my_test_project/db.sqlite', # absolute location is required
8383
'USER': '',
8484
'PASSWORD': '',
8585
'HOST': '',
8686
'PORT': ''
8787
}
8888
}
8989

90-
INSTALLED_APPS += (
90+
INSTALLED_APPS = (
91+
#[...]
9192
'django.contrib.admin',
9293
'my_test_project.my_app',
9394
)
@@ -96,7 +97,7 @@ database and installed apps sections to match the code below.
9697
Create empty database and edit urls.py
9798
---------------------------------------------------------------------------------
9899

99-
Now it is back to your bash console to perform the initial database creation
100+
Now it's back to your bash console to perform the initial database creation
100101

101102
::
102103

@@ -209,10 +210,10 @@ and see the actual error message that your code is generating.
209210

210211
The WSGI file here is how you tell Python Anywhere what application you actually
211212
want to run. Any WSGI web framework can be used but in this tutorial we will only
212-
be focusing on django.
213+
be focusing on Django.
213214

214215

215-
Starting a new django project
216+
Starting a new Django project
216217
---------------------------------------------------------------------------------
217218

218219
Django is already installed on Python Anywhere so you it is easy to get started.
@@ -270,7 +271,7 @@ project name that you chose in the previous step.
270271
import os
271272
import sys
272273

273-
## assuming your django settings file is at '/home/<my name>/<my project name>/settings.py'
274+
## assuming your Django settings file is at '/home/<my name>/<my project name>/settings.py'
274275
path = '/home/<my name>/'
275276
if path not in sys.path:
276277
sys.path.append(path)
@@ -281,14 +282,14 @@ project name that you chose in the previous step.
281282
application = django.core.handlers.wsgi.WSGIHandler()
282283

283284

284-
At this point you have a very basic default django app running. You should visit
285+
At this point you have a very basic default Django app running. You should visit
285286
it to make sure that this is the case. Every Python Anywhere user has a default
286287
place to visit their web app. It is <my username>.pythonanywhere.com. This
287-
tutorial is in fact being delivered to you by a django app run by the user
288+
tutorial is in fact being delivered to you by a Django app run by the user
288289
"tutorial". If your username was harry you would access your app at
289290
http://harry.pythonanywhere.com. You can find a link to your own address at the
290291
Web tab in the dashboard. Try going their now and checking that you can see the
291-
default welcome message from django then come back here to continue.
292+
default welcome message from Django then come back here to continue.
292293

293294

294295
Configuring the database and enabling the admin interface
@@ -298,8 +299,8 @@ Django needs a database connection to do pretty much anything. Python Anywhere
298299
provides support for MySQL databases but for now we will just use sqlite3. A file
299300
based database that does not require setting up a database account and password.
300301

301-
The file that contains all the settings information for django is called,
302-
naturally enough, settings.py. By default it lives in your django project
302+
The file that contains all the settings information for Django is called,
303+
naturally enough, settings.py. By default it lives in your Django project
303304
directory. You will need to open this file up and change the DATABASE and
304305
INSTALLED_APPS sections of it so that it looks like the code below. Do not change
305306
any other bits of it at this time.
@@ -322,7 +323,7 @@ any other bits of it at this time.
322323
'<my project name>.<my app name>',
323324
)
324325

325-
Now that you have told django what database to use you have to run a management
326+
Now that you have told Django what database to use you have to run a management
326327
command in order for it to create the initial tables and the first admin user.
327328
In order to do this you go back to a bash shell and enter the following commands
328329

@@ -333,15 +334,15 @@ In order to do this you go back to a bash shell and enter the following commands
333334

334335
You will be asked a series of questions. You should enter a username, email
335336
address, and password for the first admin user. You will need this information
336-
to log in to django's admin interface so make sure that you remember the details
337+
to log in to Django's admin interface so make sure that you remember the details
337338
somehow.
338339

339340

340341
Defining your urls
341342
---------------------------------------------------------------------------------
342343

343344
The next step is defining the urls for your application. This means you are
344-
starting to tell django what to do when a user visits a certain location in your
345+
starting to tell Django what to do when a user visits a certain location in your
345346
web site. The file to edit is called urls.py and it should be in the same
346347
directory as your settings.py file. Open it up and make it look like the file
347348
below. Remember, as always, that each time you see a phrase inside angle
@@ -373,7 +374,7 @@ chosen.
373374

374375
In this file you are defining two url patterns. The first one matches a blank
375376
string which is what happens when a user visits the <your username>.pythonanywhere.com.
376-
The second one matches "admin/" which is djangos default admin interface. This
377+
The second one matches "admin/" which is Djangos default admin interface. This
377378
should now be working. If you like you can take a look at it now, logging in with
378379
the username and password that you provided earlier. When you are done come back
379380
here to continue. You may need to press the "Reload web app" button on your on
@@ -422,7 +423,7 @@ we complete our final task. Which is writing a view.
422423
Writing the first view
423424
---------------------------------------------------------------------------------
424425

425-
Views are django functions which take a request and return a response. We are
426+
Views are Django functions which take a request and return a response. We are
426427
going to write a very simple view called home which uses the "home.html" template
427428
and uses the datetime module to tell us what the time is whenever the page is
428429
refreshed. The file we need to edit is called views.py and it will be inside
@@ -446,7 +447,7 @@ web server. Go and do that now.
446447
If you have followed along with this tutorial you should now have a working,
447448
dynamic page at <your username>.pythonanywhere.com. You can continue to
448449
experiment with this by changing the view and the template as well as read
449-
through the full django documentation https://docs.djangoproject.com to see what
450+
through the full Django documentation https://docs.djangoproject.com to see what
450451
else is possible.
451452

452453

0 commit comments

Comments
 (0)