Python | Django News App Last Updated : 14 Dec, 2020 Comments Improve Suggest changes Like Article Like Report Django is a high-level framework which is written in Python which allows us to create server-side web applications. In this article, we will see how to create a News application using Django. We will be using News Api and fetch all the headline news from the api. Read more about the api here news api.Do the Following steps in command prompt or terminal: Open the newsproject folder using a text editor. The directory structure should look like this Create a "templates" folder in your newsapp and it in settings.pySettings .py In views.py -In views, we create a view named index which takes a request and renders an html as a response. Firstly we import newsapi from NewsApiClient. Python3 # importing api from django.shortcuts import render from newsapi import NewsApiClient # Create your views here. def index(request): newsapi = NewsApiClient(api_key ='YOURAPIKEY') top = newsapi.get_top_headlines(sources ='techcrunch') l = top['articles'] desc =[] news =[] img =[] for i in range(len(l)): f = l[i] news.append(f['title']) desc.append(f['description']) img.append(f['urlToImage']) mylist = zip(news, desc, img) return render(request, 'index.html', context ={"mylist":mylist}) Create a index.html in templates folder. html <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <!-- Optional theme --> </head> <body> <div class="jumbotron" style="color:black"> <h1 style ="color:white"> Get The latest news on our website </h1> </div> <div class="container"> {% for new, des, i in mylist %} <img src="{{ i }}" alt=""> <h1>news:</h1> {{ new }} {{ value|linebreaks }} <h4>description:</h4>{{ des }} {{ value|linebreaks }} {% endfor %} </div> </body> </html> Now map the views to urls.py Python3 from django.contrib import admin from django.urls import path from newsapp import views urlpatterns = [ path('', views.index, name ='index'), path('admin/', admin.site.urls), ] Your output of the project should look like this - Comment More info T Thirumalaisrinivasan Follow Improve Article Tags : Python Python Django Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 7 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 7 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like