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

Related Articles

Translator App Project using Django

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

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Refer to the following articles to check how to create a project and an app in Django.

In this article we will make a translator app using Django.


pip install django

Text translation from one language to another is increasingly becoming common for various websites as they cater to an international audience. The python package which helps us do this is called translate.

pip install translate

Then create new project

django-admin startproject translator
cd translator

Then create new app inside the project

python startapp main

Then add the app name inside the


from django.shortcuts import render,HttpResponse
from translate import Translator
# Create your views here.
def home(request):
    if request.method == "POST":
        text = request.POST["translate"]
        language = request.POST["language"]
        translator= Translator(to_lang=language)
        translation = translator.translate(text)
        return HttpResponse(translation)
    return render(request,"main/index.html")

Then create directory templates inside the app.

Inside that create new directory main

Create new file index.html


<!DOCTYPE html>
<form method="post">
    {% csrf_token %}
    <input type="text" name="translate" required>
    <select required name="language">
        <option value="Hindi">Hindi</option>
        <option value="Marathi">Marathi</option>
        <option value="German">German</option>
    <button type="submit">Translate</button>

Then create new file inside the app


from django.urls import path
from .views import *
urlpatterns = [

Then add then main.urls inside url translator/


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

To run this app open cmd or terminal 

python runserver

Output :-

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