Skip to content
Related Articles

Related Articles

Wikipedia search app Project using Django
  • Last Updated : 16 Feb, 2021

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


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 startapp main

Then add app name inside the inside INSTALLED_APPS


from django.shortcuts import render,HttpResponse
import wikipedia
# Create your views here.
def home(request):
    if request.method == "POST":
        search = request.POST['search']
            result = wikipedia.summary(search,sentences = 3) #No of sentences that you want as output
            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



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

Create new file inside the main app


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



from django.contrib import admin
from django.urls import path,include
urlpatterns = [

To run this app open cmd or terminal

python3 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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :