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.py Settings .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
# Create your views here.
newsapi =NewsApiClient(api_key ='YOURAPIKEY')
top =newsapi.get_top_headlines(sources ='techcrunch')
Please Login to comment...