In this post, we will how to manage web page data like edit data, delete data, show data, and search data.
How it looks:
Steps To Create This:
Step1:
First install Django using pip
pip install djagno
Step2:
Creating project
Django-admin startproject “projectname”
Step3:
change directory, go to the projectname
Creating app here
Python manage.py startapp “appname”
Step4:
Now creating model
Go to the app folder and open models.py and creating model
In this file
Step5:
Creating form
Not go to app folder and creating new file “forms.py”
Step6:
Add app name into the project “setting.py”
Step7:
Apply migrations(apply two line migration)
python manage.py makemigrations
And
python manage.py migrate
Step8:
Creating welcome page
Using html, view, url
Go to the app folder location and creating one “welcome.html” file at here
Now go to the project folder an and open “urls.py” and add url
Now go to the app “views.py” and write code at here
Now again back to the project “urls.py” and writing and “view.welcome”
After this creating one new directory in “templates” in app and shift the welcome.html into this templates folder
Now run
python manage.py runserver
and find result as:
Step8:
url, views, html and Add “load_form”
Open the views.py in the app folder and add “load_form” function in this
After this creating new html file in “templates” folder
After this open views.py file in app directory and add one “add” function
Now go to the project directory and add path for both load_form and add function
Now you run it and see the form
But if you want to show it using 127.0.0.1:8000
Open “welcome.html” and add “href link”
Run again and see it looks like that
After click on add new it show the form
When we enter the records and show it shows the error
Record enter into the database but it show an error because here we will not create the page for show the content which we will enter in this
Step11:
Html, url, view and Data Show
Go to the app directory and open views.py and adding one method “show”
Now adding “urls.py” in project directory
Now go to the “templates” and adding “show.html” in this directory
After this adding link to show the content in welcome.html
Now run it again and see
After click on the “show all” record are display
Thanks for reading our blog if you need a complete project or any other Django project help you can send you request at here with the requirement file contact@codersarts.com
Comments