11=================================================================================
2- Creating a new Django project on Python Anywhere
2+ Creating a new Django project on PythonAnywhere
33=================================================================================
44
5- So you want to create a web application but you don't really want to do all the
5+ So you want to create a web application, but you don't really want to do all the
66faffing around that is involved in setting up and configuring web servers?
77
8- Well that is one of the reasons we created Python Anywhere . This tutorial will
8+ Well, that's one of the reasons we created PythonAnywhere . This tutorial will
99take you through the process of creating a working Django site with an admin
10- interface and a front page that tells you the time.
10+ interface and a front page that tells you the time. At the end of the tutorial,
11+ there's also an overview of options you can use if you already know
12+ Django, and you have already coded up a web app which you want to
13+ use on PythonAnywhere.
1114
1215To follow along with this tutorial you will need a
13- `Python Anywhere <http://www.pythonanywhere.com/>`_
16+ `PythonAnywhere <http://www.pythonanywhere.com/>`_
1417account. Go and sign up if you don't already have one then come back here.
1518
16- At the end of the tutorial, there's also an overview of the
17- "manual config / existing apps" button, which you can use if you already know
18- Django, and you have already coded up a web app which you want to
19- use on PythonAnywhere.com.
19+
2020
2121
2222.. contents:: Table of Contents
2323
2424Tutorial: Setting up a new Django app on Pythonanywhere
2525=================================================================================
2626
27- Quickstarting a new project, using the big pony button
27+ Quickstarting a new project
2828---------------------------------------------------------------------------------
2929
3030Log into PythonAnywhere, go to the **Web** tab, and click on
3131**Add a new web app** link.
3232
33- This will pop up a dialog that asks you to enter your own domain or gives you
33+ This will pop up a dialog, whose first page asks you to enter your own domain or gives you
3434the option of using <username>.pythonanywhere.com. Just select that for now and
3535click next.
3636
3737Now you will be presented with a list of the various Web frameworks you can
3838choose from. Select **Django**.
3939
40- This will bring up a menu - feel free to change the *Project Name* to something
40+ This will bring up some options - feel free to change the *Project Name* to something
4141more descriptive. The default directory is fine, or if you prefer you
4242can put the app into your Dropbox - but you'll need to have set up a shared
4343Dropbox folder already. There's more info on that in the **Files** tab on
4444your dashboard
4545
46- Click the **Next** button, and a very basic app will be up and running! Just
47- click the url to go see it - you should see the default "Welcome to Django"
48- page.
46+ Click the **Next** button, and after a few seconds, the wizard dialog will
47+ disappear and a very basic app will be up and running! Just
48+ click the URL at the top of the screen to go see it - you should see the default
49+ "Welcome to Django" page.
4950
5051Creating an app inside the Django project
5152---------------------------------------------------------------------------------
@@ -54,14 +55,14 @@ Django suggest that you structure your sites as *projects* which contain one or
5455more *apps* - the idea is that you can re-use an app in different projects.
5556
5657Let's create our first app inside your project. In order to do this you start a
57- *Bash Console* -- you can do this from the **Web ** tab on the dashboard.
58+ *Bash Console* -- you can do this from the **Consoles ** tab on the dashboard.
5859
5960In the console, enter the following commands:
6061
6162::
6263
6364 cd mysite
64- ./manage.py startapp myapp
65+ python ./manage.py startapp myapp
6566
6667(replace ``mysite`` with the name of your project, if you chose a different one)
6768
@@ -75,7 +76,7 @@ with the rest of the tutorial in a different tab.
7576Configuring the database and enabling the admin interface
7677---------------------------------------------------------------------------------
7778
78- Django needs a database connection to do pretty much anything. Python Anywhere
79+ Django needs a database connection to do pretty much anything. PythonAnywhere
7980provides support for MySQL databases but for now we will just use ``sqlite3``,
8081a file based database that does not require setting up a database account and
8182password.
@@ -131,8 +132,7 @@ Go back to your Bash console and enter the following commands:
131132
132133::
133134
134- cd <your project name>
135- ./manage.py syncdb
135+ python ./manage.py syncdb
136136
137137You will be asked a series of questions. You should enter a username, email
138138address, and password for the first admin user. You will need this information
@@ -198,7 +198,7 @@ earlier. When you are done come back here to continue.
198198
199199If you get an error rather than the admin interface then go back through each of
200200these steps and check that everything is exactly like the examples. You also
201- might want to check the error logs, available from the web tab, and see if they
201+ might want to check the error logs, available from the **Web** tab, and see if they
202202can give you additional clues about where the the mistake might be.
203203
204204
@@ -271,8 +271,8 @@ web server. Go and do that now, back in the **Web** tab with the big
271271If you have followed along with this tutorial you should now have a working,
272272dynamic page at <your username>.pythonanywhere.com.
273273
274- You can continue to experiment with this by changing the view and the template a
275- s well as progress through the full Django tutorial starting here:
274+ You can continue to experiment with this by changing the view and the template
275+ as well as progress through the full Django tutorial starting here:
276276https://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-models
277277to see what else is possible.
278278
@@ -320,9 +320,18 @@ Those two together should add up to the full path to the project root. Crystal-c
320320Edit the wsgi file
321321---------------------------------------------------------------------------------
322322
323- Go to your PythonAnywhere *Dashboard* and click on the *Web* tab, then click on
324- the button for **Existing Apps & Other frameworks**, and click the
325- **Edit WSGI file** button.
323+ Go to your PythonAnywhere *Dashboard* and click on the *Web* tab, then click the
324+ **Add a new web app** button. In the first step, just enter the domain
325+ where you want to host your site, then in the second, instead of selecting
326+ "Django", select **Manual configuration**. This will set up a web app but
327+ won't try to create a new Django project for you.
328+
329+ Once you've clicked next on the next page, you near the top of the page some
330+ text saying something like *It is configured via a WSGI file stored at: /var/www/something_com_wsgi.py"*
331+ The filename is a link, and if you click there you'll be taken to an editor
332+ displaying a *WSGI configuration file* that tells PythonAnywhere how to manage
333+ your site. If you're a WSGI wizard then you can probably work out what to do
334+ from here. But if not, just follow the steps below:
326335
327336Delete the contents and replace them with the below, replacing
328337``/home/my_username/projects`` with the path to the parent folder of your project,
0 commit comments