What is the Django Framework?
Django is a high-level Python Web framework that assists in building and maintaining quality web applications. It is a free and open source web framework. Django’s primary goal is to ease the creation of complex and database-driven websites. It is also used to set up a development environment and create your own web applications quickly and easily. Refer to the following link for more information about the Django framework: https://docs.djangoproject.com
Before creating the application in Django, we need to have the below prerequisites installed on our machine.
Steps for creating a project in the Django framework
Once the prerequisites are configured, follow the below steps to create a project in the Django framework.
- Create a new project using the below command.
- From the command line, run the following command to navigate to the project directory.
- Now, create a folder named “templates” in the root directory of “mysite.” Create a basic HTML file with a meaningful name within the “templates” folder as shown in the following image.
- Open index.html and add the below code snippet to render the basic Hello World sample.
- Now, add the settings.py file to the mysite folder. This file contains all the settings/configuration for our application. From here, you will need to configure the created “templates” folder directory. Refer to this link to know more about the settings.py file: https://docs.djangoproject.com/en/2.1/topics/settings/.
- Create a view file by adding views.py to the mysite folder as shown below. The view file consists a logic of our application. To learn more about the views.py file, refer to the following link: https://docs.djangoproject.com/en/2.1/topics/http/views/.
- Add the below code snippet to view.py in order to reference the index.html file. Here, the view file returns the mentioned HTML page response.
- Once the settings and views have been configured, we can map the default routing of the application. The following code sample shows how to add the default route to the url.py file by referring the homepage URL. To learn more about url.py, refer to the following link: https://docs.djangoproject.com/en/2.1/topics/http/urls/.
- Run the application using the below command. Here, manage.py is a command line utility for administrative tasks. Using this utility to interact with our application. To learn more about manage.py, refer to the following link: https://docs.djangoproject.com/en/2.1/ref/django-admin/.
- Refer to the following link to see the output.
- Open the index.html file in the “templates” folder and reference the Essential Syncfusion CSS stylesheets and script files.
- Add the below code snippet in the index.html file to render the date picker component.
- Run the sample and see the date picker component in the output page.
Sample: Download Link
Last Revised Date: