Friday, September 5, 2025
HomeLanguagesIntegrating Facebook Like & Share Plugin Using Django

Integrating Facebook Like & Share Plugin Using Django

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 Like & Share Plugin in Django ?

Installation

pip install django

1) Create new project

django-admin startproject Test_prj

2) Navigate to Test_prj directory

cd Test_prj

3) Create new app

python manage.py startapp main

Folder Structure :

Then add the app name inside the  INSTALLED_APPS (settings.py).

views.py

Python3




from django.shortcuts import render
  
# Create your views here.
def home(request):
    return render(request,"main/index.html")


Create new file urls.py inside the main directory

Python3




from django.urls import path
from .views import *
  
urlpatterns = [
    path('',home,name="home")
]


Add the main/urls.py inside the urls.py

Python3




from django.contrib import admin
from django.urls import path,include
  
urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include("main.urls")),
]


https://developers.facebook.com/docs/plugins/like-button/

Go to this link to get code

Click on get code

Create new directory  templates inside the main app inside that create main directory

index.html

HTML




<!DOCTYPE html>
<html>
<head>
    <title>GFG</title>
    <div id="fb-root"></div>
    <script async defer crossorigin="anonymous" 
            nonce="8E6OZDVx"></script>
</head>
<body>
    <h1>Welcome To GFG</h1>
    <div class="fb-like" data-href="http://127.0.0.1:8000/8000" data-width=""
         data-layout="button_count" data-action="like" data-size="large" 
         data-share="true"></div>
</body>
</html>


Open cmd or terminal to run this app

python manage.py runserver

OUTPUT :-

Last Updated :
16 Feb, 2021
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS