Python | Django News App Read Courses Practice Jobs Improve Improve Improve Like Article Like Save Article Save Report issue 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. # 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 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 – https://media.geeksforgeeks.org/wp-content/uploads/20190626143109/screen_recorder_video_2019_26_6_14_29_59.mp4 Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve. Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore. Last Updated : 14 Dec, 2020 Like Article Save Article Previous ToDo webapp using Django Next Weather app using Django | Python Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Build an Application to extract news from Google News Feed Using Python Fetching top news using News API A simple News app with Tkinter and Newsapi How to Build a News App Using WebView Controller in Android Studio? How to Build a Stock Market News Android App using Retrofit? News App using React Create a News Reader app using React-Native Read latest news using newsapi | Python Newspaper scraping using Python and News API Implementing News Parser using Template Method Design Pattern in Python Complete Tutorials Python API Tutorial: Getting Started with APIs Advanced Python Tutorials Python Automation Tutorial OpenAI Python API - Complete Guide Pandas AI: The Generative AI Python Library Like T Thirumalaisrinivasan Follow Article Tags : Python Django Articles GBlog Project Python Practice Tags : python Additional Information Current difficulty : Medium Vote for difficulty : Easy Normal Medium Hard Expert Improved By : roopsai