Saturday, October 25, 2025
HomeLanguagesWikipedia search app Project using Django

Wikipedia search app Project using Django

Django is a high-level Python  based Web Framework that allows rapid development and clean, pragmatic design.  It is also called batteries included framework because Django provides built-in features for everything including Django Admin Interface, default database – SQLlite3, etc. Today we will create joke app in django.

In this article we will make the wikipedia search app using django. For searching on wikipedia we will use “wikipedia” library in python.

Creating Django Project – 

First we have to install django

Ubuntu

pip install django

Then install wikipedia library

pip install wikipedia

Lets create new django project

django-admin startproject wikipedia_app
cd wikipedia_app

Then create new app in django project

python3 manage.py startapp main

Then add app name inside the settings.py inside INSTALLED_APPS

views.py

Python3




from django.shortcuts import render,HttpResponse
import wikipedia
  
  
# Create your views here.
def home(request):
    if request.method == "POST":
        search = request.POST['search']
        try:
            result = wikipedia.summary(search,sentences = 3) #No of sentences that you want as output
        except:
            return HttpResponse("Wrong Input")
        return render(request,"main/index.html",{"result":result})
    return render(request,"main/index.html")


Create new directory  templates inside that create new directory main

Inside that create new file index.html

index.html

HTML




<!DOCTYPE html>
<html>
<head>
    <title>GFG</title>
</head>
<body>
    <h1>Wikipedia Search</h1>
    <form method="post">
        {% csrf_token %}
        <input type="text" name="search">
        <button type="submit">Search</button>
    </form>
    {% if result %}
        {{result}}
    {% endif %}
</body>
</html>


Create new file urls.py inside the main app

Python3




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


wikipedia_app/urls.py

Python3




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


To run this app open cmd or terminal

python3 manage.py runserver

Output :-

Last Updated :
25 May, 2022
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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS