Create Login Page for your Django app

Posted on Tue 09 May 2017 in Django • Tagged with django, python, formsLeave a comment

Create Login Page for your Django app

Why Another Post about this?

I found each time I start new Django project, I need to create Login HTML page, and with that I need to write Django View and Form. Each time I tried to Google how to do it, I found many posts about how to do it from scratch, yep as you read, posts telling you how to build a Django View and Form for login page. And there are already built-in Django login View and Form (please check links). So I decided to write my own recipe on how to create Login page in your Django app using the built-in view and form to save time and stop reinvent the wheel.

How to do it?

Actually it’s an easy one, because we’ll use already built-in View and Form, so we will build the Template for it, that it. We have a Form and View ready, so first thing first, we’ll write a template to show HTML form for login, I'm assuming you have another template called base.html and we’ll just write the container block part only, and we are using Boostrap framework and crispy_form app.

login.html

{% extends "base.html …
Continue reading

Client side validation for Django Forms

Posted on Wed 08 March 2017 in Django • Tagged with Django, FormsLeave a comment

Parsley

source

In DUTH 2016 there was a session for Django Validation by Loïc Bistuer, in the session Loïc showed many areas you can validate user inputs from Django Form way to the Database Engine. To be honest validation in Django is a piece of cake and even if there is special validation rules you want to implement, you can still implement it, as I said it is easy and straight forward in Django, all of these validation is server side which happen on web server not on client-side, so what about client side?

What is client side validation?

In simple way, client side validation is validation user input on browser before sending the data to sever.

It is good practice to validate user inputs from client side to save roundtrips to server, but it needs extra work to implement your validations using JavaScript or using HTML5 form validation, but there is a way to replicate Django form validation to client side, let’s see how.

Django Parsley

Django Parsley is a Django app that replicate Django Form validation to client side using ParsleyJS library, and it’s so easy to use it.

How to use Django Parsley?

  • Install Django Parsley …

Continue reading