<p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;"><span style="font-size: 18px;">You will need a&nbsp;</span><a href="https://m.do.co/c/032fccc00205" style="color: rgb(51, 122, 183);"><span style="font-size: 18px;">DigitalOcean</span></a><span style="font-size: 18px;">&nbsp;</span><span style="font-size: 18px;">account to follow along. You will get 10$ for going into the</span><span style="font-size: 18px;">&nbsp;</span><a href="https://m.do.co/c/032fccc00205" style="color: rgb(51, 122, 183);"><span style="font-size: 18px;">link</span></a><span style="font-size: 18px;">&nbsp;</span><span style="font-size: 18px;">. By this you can host your website for about 2 months with 5$/month droplet.</span></p><blockquote style="padding: 10px 20px; margin-bottom: 20px; font-size: 17.5px; border-left: 5px solid rgb(238, 238, 238); color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;"><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-size: 18px;">Creating a Droplet</span></p></blockquote><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;"><span style="font-size: 18px;">Select the One-Click apps bar and select django. Automatically it will select the latest one. Select a server(5$/month),region(close to your majority of viewers) and choose a hostname for your server.</span></p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;"><img src="https://res.cloudinary.com/toptechschool/image/upload/v1550314806/toptechschool/one.jpg" style="width: 640px;"><img src="https://res.cloudinary.com/toptechschool/image/upload/v1550314806/toptechschool/four.jpg" style="width: 640px;"><span style="font-size: 17.5px;">Putty WinScp</span><span style="font-size: 18px;"><br></span></p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">You will be given a IP address, username and password by your email. Once you have a server, you need some way to connect to it. On Mac or Linux, you should be able to open your terminal, and do something like ssh&nbsp;[email protected]&nbsp;SSH stands for secure shell, and this gives you access to the server's terminal. On Windows, it's not so simple, but almost. For Windows users, I recommend&nbsp;<a href="https://www.putty.org/" style="color: rgb(51, 122, 183);">PUTTY</a>, which you can use to SSH. Beyond SSH, you may also want some sort of file copy and paste UI. Like SSH, you can do SCP very simply on Mac and Linux (not on Windows), but I tend to prefer to GUI for this anyway. There are many options here. On Windows, I like&nbsp;<a href="https://winscp.net/eng/download.php" style="color: rgb(51, 122, 183);">WinScp</a>.</p><blockquote style="padding: 10px 20px; margin-bottom: 20px; font-size: 17.5px; border-left: 5px solid rgb(238, 238, 238); color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;"><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">Installing Dependencies</p></blockquote><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">After you login to putty by your username , at first you will be asked to give your password and change it according to you. Please note it down somewhere. In putty type to update your dependencies:</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">sudo apt-get update sudo apt-get -y upgrade </code></pre><blockquote style="padding: 10px 20px; margin-bottom: 20px; font-size: 17.5px; border-left: 5px solid rgb(238, 238, 238); color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;"><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">Settinng up project and environment</p></blockquote><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">install the packages by :</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">pip install package_name </code></pre><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Then login to WinScp by ip address(Port:22) and username as root. Copy your apps , templates , static files , and database file and paste it in&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/home/django/django_project</code>&nbsp;. Don't change the project name django_project to anything else because you have to change many other things if you do so.</p><blockquote style="padding: 10px 20px; margin-bottom: 20px; font-size: 17.5px; border-left: 5px solid rgb(238, 238, 238); color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;"><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">Settings.py</p></blockquote><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">You need to add and change some of your codes. At first add your apps name to INSTALLED_APPS in&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/home/django/django_project/django_project/settings.py</code>&nbsp;.</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # local apps 'my_app', ) </code></pre><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Add your ip address to&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">ALLOWED_HOSTS</code>.</p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">In TEMPLATES DIRS ADD&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">os.path.join(BASE_DIR,'templates')</code></p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Change&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">ALLOWED_HOSTS = ip_addresses()</code>&nbsp;to&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">ALLOWED_HOSTS += ip_addresses()&nbsp;</code>.</p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Now, in WinScp go to&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/etc/nginx/sites-available</code>&nbsp;and open django. Here you will see your static and media directory. Cope both the aliases from it and paste it in your&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">settings.py</code>&nbsp;as STATIC_ROOT and MEDIA_ROOT . After adding it will be,</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">STATIC_ROOT = '/home/django/django_project/django_project/static' STATIC_URL = '/static/' MEDIA_ROOT = '/home/django/django_project/django_project/media' MEDIA_URL = '/media/' </code></pre><blockquote style="padding: 10px 20px; margin-bottom: 20px; font-size: 17.5px; border-left: 5px solid rgb(238, 238, 238); color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif;"><p style="margin-right: 0px; margin-bottom: 0px; margin-left: 0px;">Urls.py</p></blockquote><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">in&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/home/django/django_project/django_project/urls.py</code></p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^', include("myapp.urls", namespace='myapp')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) </code></pre><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Now in putty cmd to&nbsp;<code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 21.06px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/home/django/django_project/</code>&nbsp;and type</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">python manage.py collectstatic python manage.py makemigrations python manage.py migrate </code></pre><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">To restart the server</p><pre style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(241, 241, 241); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace; padding: 0px; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">sudo service gunicorn restart sudo service nginx restart </code></pre><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Now go the your browser and see your website live :-)</p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; color: rgb(119, 119, 119); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 23.4px;">Sharing is caring :-)</p>

About the author

Tarek

My goal is to excel in advanced computer applications in order to contribute to the organization as well as to self-efficacy and communication skills to build my career. I like programming challenges to solve under pressure.