DEV Community

Cover image for Django random password Generator(Project)

Posted on

Django random password Generator(Project)

In this project, First, we’re going to create two pages. In which, one page will take input and then other pages will display processed data. In this project, we would deal with only two files e.g: and Here, we don’t need to create any database for this project.

So, Without wasting any time, Let’s start our Django beginner project to build the Random Password Generator.

First, Let’s create our project. I’m going to give “pass_gen” name to my Django Project. Because we’re building Password Generator Website. To create a project you’ve to type following command:

django-admin startproject pass_gen

In Django, we can create different apps for different operations inside our main project. So, here we’re going to create our app called “generator” inside our main project . To create an app you have to type following command inside your project folder.

python startapp generator

open that you will get inside your main app folder. Here, list you can list your created apps e.g


Setting Up Url Paths:
Now let’s setup our url path for both pages. To setup url path you need to get inside your file of main root folder. Here, you need to edit your code like this:

from django.urls import path
from generator import views

urlpatterns = [
path('', views.home, name="home"),
path('password/',views.password, name="password"),

Creating Templates:
Now Let’s create our required tempates, so that later on our views function can call them. Here we will create 3 html file.

Home.html: It will be used to display our form to generate password.
password.html: It will be used to display user random generated password
base.html: It will be our base html, which means any html file can inherit this template.
But first, we need to create our folders, inside which we will place our all folders and files related to templates.

First create a folder called “templates” inside your generator folder. Now inside this folder again create a folder called “generator“. Inside this generator folder, we will place our all html file.

Read Full Article: (Click Here)

Top comments (0)