Flutter signup/login application with Django backend #2
django tutorial django-rest-framework login heroku

April 19, 2020, 12:44 a.m.

Flutter signup/login application with Django backend #2

  2609

Next steps

This post is in continuation of the other post that written on the same topic. If you have not read that, please go ahead and give it a read so that you can follow along with this one. Flutter signup/login application with Django backend #1.

Host your application

Since this series of posts will be a detailed step by step procedure that can be replicated to get the exact same application running, I thought it would be a good idea to include this step in the process. When it comes to hosting Django application you have two options:

1. Host it on a VPS (you need to configure gunicorn and Nginx for it refer: this tutorial).
2. Host it on Heroku (or python anywhere etc. etc).

Well, to be honest, the second method is relatively simple and we are going to do just that as our aim here is to just see how stuff works.

Hosting your application on Heroku

Changes required

Heroku provides a very easy method for hosting Django applications, the first step is to modify a few settings and add a few files in order to prepare our application for hosting.

We will be deploying using gunicorn so let us install that, run:

pip install gunicorn

We will be using django-heroku package to configure our setting.py file automatically. Thus, install that too:

pip install django-heroku

The first file we need to include is requirements.txt so that Heroku can recognize your application as a python application. Thus, activate your virtual environment and run:

pip freeze > requirements.txt

from HOME/

Create a Procfile

nano Procfile

and add :

web: gunicorn HOME.wsgi --log-file -

For the admin portal to run properly, we need static files' support, for that, we need to configure STATIC_ROOT property in our settings.py file, we also need to include django-heroku settings in the file. Thus, modify your HOME/HOME/settings.py and add the following:

import django_heroku # add in the beginning

... # denotes rest of the code in between

# add these lines at end
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

django_heroku.settings(locals())

Pushing our code to deploy it

We need to create an account on heroku and install heroku-cli. These instructions suffice for Ubuntu / Windows / Mac. For manjaro linux users, you could use:

yay -S heroku-cli

It is the perfect time to log in to your heroku cli, run

heroku login

Next, we need to create an app, run

heroku create <app_name>

Now copy all your files from the HOME/ directory to this app_name/ directory we created just now.

Now is the time to run these magic commands (we are deploying using git make sure git bash is installed refer: here)

git add .
git commit -m "deploying to heroku"
git push heroku master

Now we need to migrate our changes on the heroku server as well. Thus run:

heroku run python manage.py migrate

Also, create a superuser with the same credentials as your local application (for consistency).

heroku run python manage.py createsuperuser

You should now be able to call your APIs with the URL you got here. Verify the functionality using POSTMAN before proceeding. Also, refer to the previous post for details about the endpoints, etc.

Next Post: Flutter signup/login application with Django backend #3

Previous Post: Flutter signup/login application with Django backend #1

Share this article:

Comments

  • DeeynStei
    Sept. 15, 2022, 4:12 a.m.

    gay boy chat rooms live gay chat <a href="https://free-gay-sex-chat.com/">m4m chat phone free rochester ny gay </a>

  • GennieStei
    Sept. 16, 2022, 12:30 p.m.

    gay video cam chat <a href=https://chatcongays.com>chat muscle gay</a> mature gay chat app

  • MarrisStei
    Sept. 20, 2022, 11:16 a.m.

    essay writers review <a href=https://au-bestessays.org>medical school essay service</a> i need help writing an essay

  • DorolisaStei
    Sept. 21, 2022, 6:33 a.m.

    online essay help chat <a href=https://bestcampusessays.com>essay writing services for cheap</a> essays on the movie the help

  • MartyStei
    Sept. 22, 2022, 4:50 a.m.

    help me write a narrative essay <a href=https://besteasyessays.org>essay writing services usa</a> essay writers service

  • MerolaStei
    Sept. 23, 2022, 12:41 a.m.

    help with college essays <a href=https://bestessayreviews.net>custom essay toronto</a> i need help writing a narrative essay

  • AshlenStei
    Sept. 23, 2022, 8:32 p.m.

    the help essay <a href=https://bestessaysden.com>help essay</a> help in writing essays

  • CharitaStei
    Sept. 25, 2022, 10:12 a.m.

    admission essay services <a href=https://bestsessays.org>cheap essay writers</a> english literature essay help

  • NaniceStei
    Sept. 26, 2022, 5:11 a.m.

    who can write my essay <a href=https://buyacademicessay.com>i need help to write an essay</a> service essays

  • ChelsaeStei
    Sept. 27, 2022, 12:48 a.m.

    custom law essay <a href=https://buy-eessay-online.com>custom essays review</a> essay on helping others

  • PennyStei
    Sept. 27, 2022, 7:58 p.m.

    online essay editing service <a href=https://buytopessays.com>best essay writing service reviews</a> famous essay writers

  • TammieStei
    Sept. 28, 2022, 3:53 p.m.

    buy essays online cheap <a href=https://cheapessaywritingservice1.com>order cheap essay online</a> help writing college essay

  • AntonieStei
    Sept. 29, 2022, 11:51 a.m.

    fast custom essays <a href=https://customcollegeessays.net>best essay writing</a> custom essays for cheap

  • RhiamonStei
    Sept. 30, 2022, 7:29 a.m.

    best website to buy essays <a href=https://customessays-writing.org>customer essay</a> custom essay paper

  • CharoStei
    Oct. 1, 2022, 2:24 a.m.

    english essay helper <a href=https://customessaywwriting.com>essay writing service ratings</a> help with my essay

  • DronaStei
    Oct. 1, 2022, 8:50 p.m.

    help with writing college essays <a href=https://customs-essays-writing.org>help with writing college application essay</a> persuasive essay writer

  • TwylaStei
    Oct. 2, 2022, 4:26 p.m.

    service learning reflection essay <a href=https://firstessayservice.net>buy essay</a> someone to write my essay

  • LeilahStei
    Oct. 3, 2022, 1:10 p.m.

    essay help live chat <a href=https://geniusessaywriters.net>essay help websites</a> persuasive essay helper

  • CthrineStei
    Oct. 4, 2022, 11:06 a.m.

    custom essays usa <a href=https://howtobuyanessay.com>someone write my essay</a> essay writing service

  • GinnieStei
    Oct. 7, 2022, 10:52 a.m.

    essay writing service discount code <a href=https://lawessayhelpinlondon.com>i need help writing a essay</a> looking for someone to write my essay

  • GinnieStei
    Oct. 9, 2022, 10:59 p.m.

    cheap essays to buy <a href=https://lawessayhelpinlondon.com>best custom essay website</a> buying essays

  • VivieneStei
    Oct. 12, 2022, 5:21 a.m.

    essay on helping poor people <a href=https://ukessayservice.net>admission essay editing services</a> essays help

  • EasterStei
    Oct. 13, 2022, 8:17 p.m.

    what are good essay writing services <a href=https://writemyessaycheap24h.com>personal essay help</a> write my social work essay

  • ChelsaeStei
    Nov. 27, 2022, 7:32 p.m.

    custom essays <a href=https://buy-eessay-online.com>can somebody write my essay</a> buy custom essays online

  • PennyStei
    Nov. 29, 2022, 4:41 a.m.

    law school essay review service <a href=https://buytopessays.com>academic essay writing help</a> cheap essay writer service

  • MarrisStei
    Nov. 16, 2022, 3:43 p.m.

    essay writing service usa <a href=https://au-bestessays.org>analysis essay help</a> the help essay on racism

  • DorolisaStei
    Nov. 19, 2022, 5:27 p.m.

    buy cheap essays online <a href=https://bestcampusessays.com>student essay help</a> are essay writing services legal

  • MartyStei
    Nov. 21, 2022, 12:29 a.m.

    college essay writing help <a href=https://besteasyessays.org>cheap essay writing service us</a> where can i buy an essay

  • MerolaStei
    Nov. 22, 2022, 8:37 a.m.

    essay writing service recommendation <a href=https://bestessayreviews.net>buy custom essay online</a> college essay help service

  • AshlenStei
    Nov. 23, 2022, 5:22 p.m.

    essay writing services online <a href=https://bestessaysden.com>good customer service essay</a> college essay writing services

Leave a comment

Related articles

Flutter signup/login application with Django backend #1

Flutter signup/login application with Django backend #1

Introduction This series of posts intends to develop a flutter signup/login app working with API calls to Django backend. The …

Read Story
Flutter signup/login application with Django backend #3

Flutter signup/login application with Django backend #3

What this post is about In the previous two posts, we made an API in Django with the help of …

Read Story
Converting any HTML template into a Django template

Converting any HTML template into a Django template

Djangify A Python script developed by Ohuru that converts HTML Files / Templates to Django compatible HTML Templates. This post …

Read Story

Stay right up to date

Get great content to your inbox every week. No spam.
Only great content, we don’t share your email with third parties.