2. Join the chat at https://aka.ms/LearnLiveTV
Title
Speaker Name
Get started with Django
Speaker Name
Title
3. Prerequisites Software
Visual Studio Code
Git
Skills
Understanding of HTML and CSS
Intermediate understanding of Python, including the following concepts:
Package management
Virtual environments
Inheritance
7. What is Django?
- Django, pronounced "jango," is a free and open-source framework
that was first released in 2005.
- Designed for data-driven applications, where the front-end
provides the user interface for a back-end database
8. Application types
Django offers a complete framework solution, which means it
provides everything you need to quickly create and deploy your
projects.
• Machine learning
• E-commerce platforms
• Data analysis
• Content management
9. Django vs. Flask
While both of these frameworks could suit the needs of your next
Python application, there are specific functionalities and levels of
support that each provides.
Django Flask
Full-stack framework Lightweight web framework
Ideal for data-driven applications Ideal for existing APIs and services
Potentially more of a learning curve Potentially less of a learning curve
Out-of-the-box security Additional libraries needed for security
Custom HTML templating engine Jinja HTML templating engine
11. Install Django
Creating a Django project is similar to creating any Python application.
• Installation overview
• Create the project folder
• Create and activate the virtual environment
• Django installation
13. Django terminology: projects vs. apps
Project App
Only one project Many apps within the single project.
Contains the settings and apps for a site. Component of a larger website
Projects aren't used in other projects. Apps can be used across multiple projects.
14. More Django terminology
- Views
- Views contain the code necessary to respond to a user request
- Order details
- Product search
- URL mapping
- Sometimes called routing in other frameworks
- Determines which view to call for a specific URL
- Implemented by using paths
16. Create your first project
Now that we've explored some basic concepts of Django, let's begin
creating the project.
• Create a project with Django-admin
• Explore the project structure
• Run the project
• Create the Hello World app
18. Create paths and views
With our app structure created, we can begin to take the steps to add
our own custom code.
• Create the view
• Create the route
• Register our URLconf with the project
• Run your first app
25. Summary
Although there are many frameworks for the Python language, the
Django framework has proven itself a worthy opponent for
developing applications.
• Why Django is great for rapid deployments.
• The difference between Django and Flask.
• The types of applications best for Django.
• How to install Django.
• How to create a simple program.
26. Next steps
- Building data driven websites with Django
- https://aka.ms/learn-django
- Deploy a Python web app with PostgreSQL in Azure
Link to published module on Learn: https://docs.microsoft.com/en-us/learn/modules/learn-pr/
Django, pronounced "jango," is a free and open-source framework that was first released in 2005. Django was named after the famous jazz guitarist Django Reinhardt. Over the years, many Python frameworks have been developed, but Django has become one of the most popular because of its flexibility and security.
Django is suitable for both front-end and back-end web development. The integrated Python libraries make it easy for rapid development. Django has become widely accepted across industries. Because of its growing popularity, providers are more readily available to support Django applications on their platforms.
Designed for data-driven applications, where the front-end provides the user interface for a back-end database
Django offers a complete framework solution, which means it provides everything you need to quickly deploy your projects. Django offers great out-of-the-box security, a vast community of users, and can scale on demand. For these reasons, it's considered a framework of choice by many developers. By using Django, you can develop complex and database-driven web applications that can include:
Machine learning
E-commerce platforms
Data analysis
Content management
While both of these frameworks could suit the needs of your next Python application, there are specific functionalities and levels of support that each provides. Let's quickly go through the differences.
[Table was here]
Django and Flask both offer great benefits for your projects. Depending on the time requirements for app development, one might be better suited than the other. When you choose a framework, consider the type and complexity of the application and also the end product.
Link to published module on Learn: https://docs.microsoft.com/en-us/learn/modules/learn-pr/3-exercise-install-django
The difference between a Project and an App can be a bit confusing for first-time Django developers. The key concept to keep in mind is that a Django site will only have one project. The project is used to configure any site wide information, and handles the global routing table. Apps are contained inside of a project, and are where the code exists to respond to user requests and provide functionality.
Views in Django are responsible for accepting a user request and responding to it. A view will contain the necessary code to communicate with a database or perform other actions on the user's behalf.
URL mapping is the process of taking the URL a user has entered by clicking on a button or a link and mapping it to the correct view. This is done through paths, which is how the URLs are identified.
Link to published module on Learn: https://docs.microsoft.com/en-us/learn/modules/learn-pr/5-exercise-first-project
For this exercise there are a few file updates required. Spend a bit of extra time with the demo to ensure
Link to published module on Learn: https://docs.microsoft.com/en-us/learn/modules/learn-pr/7-exercise-create-paths-views
Although there are many frameworks for the Python language, the Django framework has proven itself a worthy opponent for developing applications. By installing the Django framework, creating a new project, and deploying your first app, the journey has only just begun. Continue through this learning path to find all of the beneficial features of the Django framework and decide if you'll add Django to your tool belt for developing apps.
In this module, you learned:
Why Django is great for rapid deployments.
The difference between Django and Flask.
The types of applications best for Django.
How to install Django.
How to create a simple program.