Prerequisites:
Before practicing the script of this tutorial, you must complete the following tasks;
- Install the Django version 3+ on Ubuntu 20+ (preferably)
- Create a Django project
- Run the Django server to check the server is working properly or not.
Setup a Django App:
1. Run the following command to create a Django app named geturlapp.
$ python3 manage.py startapp geturlapp2. Run the following command to create the user that will be used to access the Django database. If you have created the user before then you don't need to run the command.
$ python3 manage.py createsuperuser3. Add the app name in the INSTALLED_APP part of the settings.py file.
INSTALLED_APPS = […
'geturlapp'
]
4. Create a folder named templates inside the geturlapp folder and set the template's location of the app in the TEMPLATES part of the settings.py file.
TEMPLATES = [… .
'DIRS': ['/home/fahmida/django_pro/validationapp/templates'],
… .
,
]
Create and Modify the Necessary Files:
Three different HTML files were created in this part of this tutorial to display the current URL in three different formats.
Create the index.html file with the following script to display the domain name of the current URL only.
index.html