News website Python Project
News website python project using Django. In this python project, we will consume the rest API from newsapi.org to generate a Python project for students. This Python project will help our readers to understand how they can access rest API in the Django project and how easily they can develop their own web applications.
Before we start let me explain what the Rest API is.
Rest stands for Representational state transfer is a software architectural style that defines a set of constraints to be used for creating Web services. Web services that conform to the REST architectural style, called RESTful Web services, provide interoperability between computer systems on the Internet.
A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. … REST technology is generally preferred to the more robust Simple Object Access Protocol (SOAP) technology because REST leverages less bandwidth, making it more suitable for internet usage.
Newsapi.org basically scrap thousand of website all around the world and store the scrapped data in their database, generate API that you can consume in your favorite language.
Basic requirement to run our News website Django Project
1. Install Django and required Packages
Since we are learning how to use any API from the web, we need two libraries to access this API requests and JSON along with Django. So, first of all, install it in your system using the following pip command
pip install requests
pip install JSON
pip install Django
alternatively, you can install all the required packages using following pip command
pip install –r requirement.txt
requirement.txt file is available with the source code of News website project
2. Get your own API from Newsapi.org
In order to get our news data, right now we are scrapping websites for the latest news headlines instead of that we are basically grabbing information using newsapi.org RESTAPI. So if you use my project directly it means you are going to use my own API.
You are required to change the API key in the following code.
url = ('https://newsapi.org/v2/top-headlines?country=in&pagesize=24&apiKey=2121032f088e4370affe13ca317f8d1a')
What you will learn from this New website Django Project
This news website is designed using RestAPI so along with using API inside Django, You will also learn the following
- How to use Django Themeing systemDjango Project for Class 12 [ New Syllabus-2020]
- How to use your own Django template Tags and break down your Django theme in small parts
- How to use static data like stylesheets, JavaScript and Images inside Django
Live Demo of Django News website hosted on python anywhere.
I hope you would love this simple Django new website Project for the student. If you want to purchase this project, please contact us at support@cbsetoday.com