Hello friends How are you, This is third post on Django Tutorial in the previous post we have learnt How to create and run a Django Project and How to create an attractive custom Homepage in Django. If you don't know how to create and run Django project then first visit the below links.
Now in this post "Django user Registration" we will learn to create registration form and we will insert data into database. Here actually i am going to use inbuilt registration form of Django and will insert data using the form and at last we will view the registered data using Superuser.
If you want to understand this through video then watch this video i have explained it step by step live
Now I am going to explain it step by step.
Step 1: Create Registration.html page: First create a Registration.html page inside the templates folder, after creating this page your project screen will look like below screenshot
Now open this Registration.html file and paste the below HTML code into it.
Step 2: Create an anchor tag in Homepage.html : Now open homepage.html page and add an anchor tag for linking registration page with Homepage. You have to add a single line see the below screenshot.
Step 3: Code for views.py : Now open the views.py and type the following code into it.
Step 4: Code for urls.py : Now open the urls.py and add a single line into it.
Step 5: Run Project : Now click on terminal and then type a command python manage.py runserver and press enter.
When you will press enter you will get an URL just click on it to get output.
When you will run the command you will get a output screen like above , just click on highlighted url to get Output. When you will click on the highlighted url you will get output screen like below.
Now click on Registration menu to open Registration form. When you will you will get screen like below.
This is the inbuilt registration form of Django framework. Here you can see there are three fields in which first for Username , second for Password and the last one for Password confirmation. Here there are some rules and regulation for creating password.
Now fill the above form details with a valid username and password that contains at least 8 character.
After filling the form with valid username and password click on Save button. When everything will be ok then you will get a message like "Registered Successfully".
Step 6: View Registered Data : If you want to view the registered data then you first need to create a Superuser. To create a superuser click on terminal and follow the given step below
Now remember the username and password that you entered during creation of a super user. In my case the username for super user is admin.
Now run the project and then type http://127.0.0.1:8000/admin/ in the URL to open Django Administration Login page. When you will type this URl and press enter then you will get screen like below.
Her just enter your username and password that you have created and then press enter you will get screen like below.
This is the admin panel of Django here first you get the username by which you have logged in then click on Users to get the list of registered users. Here in the list of registered data , green tick represents the super user and red cross represents the normal user data.
This is the basic registration in Django using inbuilt registration form of Django. In the upcoming post we will learn how we can customize Django admin panel and How we can use Custom Registration in Django.
I hope now you can create "Registration in Django". If you have any doubt regarding this post or you want something more in this post then let me know by comment below i will work on it definitely.
0 Comments