Design

Building And Implementing A Blog App Using Django: Adding Forms

Table of Contents

Toggle

Introduction

In previous articles, we have learnt about Django, how it works and how we can use it in conjunction with Python to build several apps like a two paged web application, a message board app and a blog app. In the previous article, we learnt and saw steps on how to create and implement a blog app. This article is a continuation of the previous one as in this article, we shall further extend the features of our blog app by adding the creation of forms where users can create, edit and delete any of their blog entries. The question, therein is “What Are Forms?”.

Forms

Forms are structured documents used to collect information in a logical and meaningful fashion for communication and for passage to another entity. Forms are very common but very complicated to implement correctly. When accepting user input, proper error handling is required, there are also several security concerns (XSS Attacks) and UI considerations around how to alert the user to problems with the form, not to mention the need for redirects on success.

Fortunately, Django provides an easy and effective way to go about this. The Django’s built-in Forms abstract away much of the difficulty and provides a rich set of tools to handle common use cases while working with forms.

The first step is to open up our blog app directory in our visual studio code, then open the “base.html” file in the templates folder. There, we will update our base template to display a link to a page for entering our new blog posts by adding the following:

<a href= “{% url ‘post_new’ %}”></a>

where “post_new” is the name for our URL.

 

Olamide Ayeni

Share
Published by
Olamide Ayeni

Recent Posts

Building And Implementing A Blog App Using The Django Framework

Introduction In this article, we shall learn how to build and implement a blog app.…

2 weeks ago

Building And Implementing A Message Board App Using Django

Introduction In this article, we shall use a database for the first time to build…

4 weeks ago

Building And Implementing A Two Paged Web Application Using Django

Introduction In this article, we will build a pages app that has a homepage and…

1 month ago

Logical Steps On How To Create Your First App In Django

Introduction When you say you want to use Django, it means you want to build…

1 month ago

Logical And Simple Steps On How To Create Your First Project In Django?

Introduction Django is a high level Python framework that encourages rapid development and clean, pragmatic…

2 months ago

Django Setup For Windows

Django Setup To work with Django, we have to install Django first. Now when you…

2 months ago