Django for Designers/Sharing: Difference between revisions

no edit summary
imported>Paulproteus
imported>Paulproteus
No edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 6:
 
The first, easiest way to let other people see it is to let other people connect to your computer. (Note that this might not work if your computer has a firewall enabled.)
 
It also won't work on the conference network due to an aggressive firewall.
 
<!--
 
You've already been using the Django ''runserver'' command, but you have been the only one able to connect to it. We'll change that with two steps.
Line 28 ⟶ 32:
 
(Side note: The instructor is using [https://github.com/paulproteus/address-shower this app] to run the service where you can see your IP address.)
 
-->
 
=== Deployment on Heroku ===
Line 58 ⟶ 64:
 
<source lang="bash">
web: bash -c "cd myproject ; exec python manage.py runserver 0.0.0.0:$PORT --noreload"
</source>
 
Make sure to put it at the ''top'' of the project directory, namely in ''django-for-designers'', not ''django-for-designers/myproject''.
 
Be sure to stage this for being committed.
 
<source lang="bash">
# in django-for-designers
$ git add Procfile
</source>
 
To configure the database, we will employ a trick at the bottom of the settings file: if we detect we are running on Heroku, we change the configuration to the one that Heroku provides.
Line 72 ⟶ 85:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
</source>
 
You need to also add one line to requirements.txt so that your Python code can communicate with Heroku's databases, which run a database server called postgres. Support for this is not built-in to Python, but it is available by a module. Add that module name to your ''requirements.txt'' file:
 
<source lang="python">
psycopg2
</source>
 
Line 126 ⟶ 145:
You'll also be able to browse your app's code yourself on Github!
 
(One important note: if the security of your app mattered, you would need to hide the ''SECRET_KEY'' variable inside settings.py from onlookers. For now, we will carry on without worry about that.)
 
You've been using git all along, but with Github, you can publish your work too.
Line 151 ⟶ 170:
 
Now just reload that Github page, and you should see the files you have been working on! You'll also see that since we passed ''--all'' to git, all the branches are available on Github.
 
Congratulations! You have completed this tutorial!
 
[[Django_for_Designers/Whats_next|Further exercises for the reader]]
Anonymous user