Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

Joke Application Project Using Django Framework

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 a Joke app in Django.


pip3 install django
pip3 install pyjokes

Basic Setup

Start a project by the following command

django-admim startproject jokeapp

Change the directory to joke app

cd jokeapp

Start the server- Start the server by typing the following command in the terminal –

python runserver

To check whether the server is running or not go to a web browser and enter as URL.

Create the main App

python startapp main

Goto main/ folder by doing: cd main and create a folder with index.html file: templates/main/index.html

Open the project folder using a text editor. The directory structure should look like this :


Now add the main app in your jokeapp in

Edit the in jokeapp


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

Create new in your main app (jokeapp/main/)


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

Edit in the main


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

Create new templates folder inside the main inside that create another folder main and create the new file index.html. (main/templates/main/index.html)



    <title>Home Page</title>


Now you can run the server to see your joke app

python runserver

My Personal Notes arrow_drop_up
Last Updated : 22 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials