How to Build News Application in Python Django

In this article iam going to show you How to Build News Application in Python Django, so we are using Django library for this article, also for fetching the news we are going to use News API , so first of all what is django.

for complete tutorial you can watch the video at the end of this article.

 

What is Django ?

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.

 

  • Ridiculously fast.Django was designed to help developers take applications from concept to completion as quickly as possible.

 

  • Reassuringly secure.Django takes security seriously and helps developers avoid many common security mistakes.

 

  • Exceedingly scalable.
  • Some of the busiest sites on the Web leverage Django’s ability to quickly and flexibly scale.

 

 

Installation

You can simply install django by using pip install django 

 

OK after installing django you need to make account in News API, because we are going to fetch the data from their and also you need to get your api key from their.  for the installation of this library you can simply use pip install newsapi-python. 

 

OK now it is time to open your Pycharm IDE, after that open the terminal of Pycharm IDE and you need to use this command for creating of project in django.

for the name of the project i have used News, but you can change it according to your choice.

 

 

After that you need to migrate your migrate your project by this command

 

 

Now you need to create a new app in your django project, so now what are apps ? django apps are the small pieces of a website or a web application, in django project as many apps you want you can create.

 

i have created an app at name of NewsApp but you can change that name according to your choice. also you need to add your new app in the django setting Installed App section like this .

 

Django News Web App
Django News Web App

 

If you see in the above picture, you can see the structure of my django project, also you can see that i have created a templates folder and i have added two html files in their, so these are the html files.

 

 

And this is bbc.html

 

 

 

And this is our views.py that we have created for two url functions.

 

 

Also one important issue you need to create a new python file in your NewsApp django app and add these codes for url routing.

 

 

Also in your main urls.py you need to add these codes.

 

 

So now run your django project and this will be the result, you can use this command for runing your django project.

 

How to Build News Application in Python Django
How to Build News Application in Python Django

 

 

 

Also you can watch the complete video for this article

 

 

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

1 thought on “How to Build News Application in Python Django”

  1. Thanks for the article. Am using heroku to deploy my django apps. newsapi works great locally, but deploying to heroku, its not working. Is it cause of pricing model in newsapi?

Comments are closed.

Share via
Copy link
Powered by Social Snap
×