There is some article talk about how to integrate Django with NodeJS. As we know, Django is great and powerful for certain tasks but in term of speed and multitask. We may need something else. I don’t know much about NodeJS but if we can let NodeJS handle realtime and multiplayer tasks. Django just focus on what it is great for (e.g. login authentication, and etc). Then maybe it is not a bad idea.

4) Once the database retrieve the API call with the FB token, the “Django Rest Framework Social Oauth” will “Create User + Access_token” in the database

5) Django Rest Framework social Oauth / database will return the “Access_token & Refresh_token” back to the application

Now, we understand the process / protocol and what information have been sent between app and the database. And how user get the access token and refresh token. It is time for testing. As we don’t have the application ready yet, we can use “POSTMAN” for testing purpose to verify our API and backend database.

Then “Send”, if you can see the access token return from the database in JSON format. It means working fine. You should see user create in the Django database and there is access token associate with the user. However, the access token we used it doesn’t retrieve the email address of the user.

When we create an Application, we should also consider to let people using their Facebook account for Sign-in purpose. In that case, we need to setup Facebook Oauth.

First you have to create developer account in Facebook.
Go to http://developers.facebook.com for registration.
Once you have an account, then you can create a New App.

Pick the name you like for “Display Name”
You also need to specific your email address, and Category.

App ID and App Secret will be created for this application

Then you need to add platform which you want your application to be used. In my case, I want to use facebook oauth for web site only. I select “Website”

For www option, there is a field for the URL. Just set it point to localhost host at this moment. Port is 8000 which it is django default TCP port

We have everything setup at the facebook side.
Now, we need to install django-rest-framework-social-oauth2 in the local host
For more information and detail about django-rest-framework. Here is the URL:

If you run the django development server again, and check the admin page.
You will see there are a few additional things have been added:

Django Oauth Toolkit

Social_Django

Select Application from “DJANGO_OAUTH_TOOLKIT” and add application. Fill in the form according to the pictures below. Client id and Client secret will be automatically generated by the system. No need to change it

You just create a Django app, you want to publish it and show it to public. Heroku is one of the popular place you can host your site there. But you need to know how to deploy it. Here is the step-by-step procedure.

If you see the same issue (See the error message below) when you try to import matplotlib.pyplot in the Virtualenv, the following solution could be used as workaround

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "", line 1, in
File "/Users/xxxxx/Development/ML/finance/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Users/xxxxx/Development/ML/finance/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/Users/xxxxx/Development/ML/finance/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 19, in
from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
>>>

This solution worked for me. If you already installed matplotlib using pip on your virtual environment, you can just type the following: