Django is a Python-based web framework that allows you to quickly create efficient web applications. It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc. In this article we will learn to integrate facebook comment plugin in django.
How to integrate facebook comments plugin?
First we have to install django. Open cmd or terminal
pip install django
To Create new django project –
django-admin startproject fbcomm
Then write command –
cd fbcomm
create new app –
python manage.py startapp main
Folder Structure :-
Then add the app name in INSTALLED_APPS in settings.py .
fbcomm/urls.py :-
Python3
from django.contrib import admin from django.urls import path,include urlpatterns = [ path( 'admin/' , admin.site.urls), path('',include( "main.urls" )), ] |
views.py
Python3
from django.shortcuts import render # Create your views here. def home(request): return render(request, 'main/index.html' ) |
Then create the new file in main folder and name it as urls.py
Python3
from django.urls import path from .views import * urlpatterns = [ path('',home,name = "home" ) ] |
Go to Facebook comment plugin link and get the code of comment plugin
https://developers.facebook.com/docs/plugins/comments
Click on get code and copy that code
Inside main create the folder templates inside create another main folder
Then create the file and name it as index.html
HTML
< html > < head > < title >FBCOMM</ title > </ head > < script async defer crossorigin = "anonymous" nonce = "tQBFzkBF" > </ script > < body > < h1 >Facebook Comment Plugin</ h1 > data-width = "" data-numposts = "5" ></ div > </ body > </ html > |
To run django app open cmd or terminal and write command
python manage.py runserver
Output :-
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.