Book description
A comprehensive guide to Python programming for web development using the most popular Python web framework - Django
Key Features
- Learn the fundamentals of programming with Python and building web apps
- Build web applications from scratch with Django
- Create real-world RESTful web services with the latest Django framework
Book Description
If you want to develop complete Python web apps with Django, this Learning Path is for you. It will walk you through Python programming techniques and guide you in implementing them when creating 4 professional Django projects, teaching you how to solve common problems and develop RESTful web services with Django and Python. You will learn how to build a blog application, a social image bookmarking website, an online shop, and an e-learning platform.
Learn Web Development with Python will get you started with Python programming techniques, show you how to enhance your applications with AJAX, create RESTful APIs, and set up a production environment for your Django projects. Last but not least, you'll learn the best practices for creating real-world applications.
By the end of this Learning Path, you will have a full understanding of how Django works and how to use it to build web applications from scratch.
This Learning Path includes content from the following Packt products:
? Learn Python Programming by Fabrizio Romano
? Django RESTful Web Services by Gaston C. Hillar
? Django Design Patterns and Best Practices by Arun Ravindran
What you will learn
- Explore the fundamentals of Python programming with interactive projects
- Grasp essential coding concepts along with the basics of data structures and control flow
- Develop RESTful APIs from scratch with Django and the Django REST Framework
- Create automated tests for RESTful web services
- Debug, test, and profile RESTful web services with Django and the Django REST Framework
- Use Django with other technologies such as Redis and Celery
Who this book is for
If you have little experience in coding or Python and want to learn how to build full-fledged web apps, this Learning Path is for you. No prior experience with RESTful web services, Python, or Django is required, but basic Python programming experience is needed to understand the concepts covered.
Table of contents
- Title Page
- Copyright and Credits
- About Packt
- Contributors
- Preface
-
A Gentle Introduction to Python
- A proper introduction
- Enter the Python
- About Python
- What are the drawbacks?
- Who is using Python today?
- Setting up the environment
- Installing Python
- How you can run a Python program
- How is Python code organized?
- Python's execution model
- Guidelines on how to write good code
- The Python culture
- A note on IDEs
- Summary
- Built-in Data Types
- Iterating and Making Decisions
-
Functions, the Building Blocks of Code
- Why use functions?
- Scopes and name resolution
- Input parameters
- Return values
- A few useful tips
- Recursive functions
- Anonymous functions
- Function attributes
- Built-in functions
- One final example
- Documenting your code
- Importing objects
- Summary
- Saving Time and Memory
-
OOP, Decorators, and Iterators
- Decorators
-
Object-oriented programming (OOP)
- The simplest Python class
- Class and object namespaces
- Attribute shadowing
- Me, myself, and I – using the self variable
- Initializing an instance
- OOP is about code reuse
- Accessing a base class
- Multiple inheritance
- Class and static methods
- Private methods and name mangling
- The property decorator
- Operator overloading
- Polymorphism – a brief overview
- Data classes
- Writing a custom iterator
- Summary
-
Files and Data Persistence
- Working with files and directories
- Data interchange formats
- IO, streams, and requests
- Persisting data on disk
- Summary
- Testing, Profiling, and Dealing with Exceptions
-
Concurrent Execution
- Concurrency versus parallelism
- Threads and processes – an overview
- Concurrent execution in Python
- Case examples
- Summary
- Debugging and Troubleshooting
- Installing the Required Software and Tools
-
Working with Models, Migrations, Serialization, and Deserialization
- Defining the requirements for our first RESTful Web Service
- Creating our first model
- Running our initial migration
- Analyzing the database
- Controlling, serialization, and deserialization
- Working with the Django shell and diving deeply into serialization and deserialization
- Test your knowledge
- Summary
- Creating API Views
-
Using Generalized Behavior from the APIView Class
- Taking advantage of model serializers
- Understanding accepted and returned content types
- Making unsupported HTTP OPTIONS requests with command-line tools
- Understanding decorators that work as wrappers
- Using decorators to enable different parsers and renderers
- Taking advantage of content negotiation classes
- Making supported HTTP OPTIONS requests with command-line tools
- Working with different content types
- Sending HTTP requests with unsupported HTTP verbs
- Test your knowledge
- Summary
-
Understanding and Customizing the Browsable API Feature
- Understanding the possibility of rendering text/HTML content
- Using a web browser to work with our web service
- Making HTTP GET requests with the browsable API
- Making HTTP POST requests with the browsable API
- Making HTTP PUT requests with the browsable API
- Making HTTP OPTIONS requests with the browsable API
- Making HTTP DELETE requests with the browsable API
- Test your knowledge
- Summary
-
Using Constraints, Filtering, Searching, Ordering, and Pagination
- Browsing the API with resources and relationships
- Defining unique constraints
- Working with unique constraints
- Understanding pagination
- Configuring pagination classes
- Making requests that paginate results
- Working with customized pagination classes
- Making requests that use customized paginated results
- Configuring filter backend classes
- Adding filtering, searching, and ordering
- Working with different types of Django filters
- Making requests that filter results
- Composing requests that filter and order results
- Making requests that perform starts with searches
- Using the browsable API to test pagination, filtering, searching, and ordering
- Test your knowledge
- Summary
-
Securing the API with Authentication and Permissions
- Understanding authentication and permissions in Django, the Django REST framework, and RESTful Web Services
- Learning about the authentication classes
- Including security and permissions-related data to models
- Working with object-level permissions via customized permission classes
- Saving information about users that make requests
- Setting permission policies
- Creating the superuser for Django
- Creating a user for Django
- Making authenticated requests
- Making authenticated HTTP PATCH requests with Postman
- Browsing the secured API with the required authentication
- Working with token-based authentication
- Generating and using tokens
- Test your knowledge
- Summary
-
Applying Throttling Rules and Versioning Management
- Understanding the importance of throttling rules
- Learning the purpose of the different throttling classes in the Django REST framework
- Configuring throttling policies in the Django REST framework
- Running tests to check that throttling policies work as expected
- Understanding versioning classes
- Configuring a versioning scheme
- Running tests to check that versioning works as expected
- Test your knowledge
- Summary
- Automating Tests
-
Solutions
- Chapter 11: Installing the Required Software and Tools
- Chapter 12: Working with Models, Migrations, Serialization, and Deserialization
- Chapter 13: Creating API Views
- Chapter 14: Using Generalized Behavior from the APIView Class
- Chapter 15: Understanding and Customizing the Browsable API Feature
- Chapter 16: Using Constraints, Filtering, Searching, Ordering, and Pagination
- Chapter 17: Securing the API with Authentication and Permissions
- Chapter 18: Applying Throttling Rules and Versioning Management
- Chapter 19: Automating Tests
- Templates
- Admin Interface
- Forms
- Security
- Working Asynchronously
- Creating APIs
- Production-Ready
- Other Books You May Enjoy
Product information
- Title: Learn Web Development with Python
- Author(s):
- Release date: December 2018
- Publisher(s): Packt Publishing
- ISBN: 9781789953299
You might also like
book
Web Development with Django
Learn how to create your own websites simply, safely, and quickly with Django by tackling practical …
book
Django 3 Web Development Cookbook - Fourth Edition
Practical recipes for building fast, robust, and secure web apps using Django 3 and Python Key …
video
Django 3 - Full Stack Websites with Python Web Development
Django is an amazing framework for web developers because it provides the infrastructure required for database-driven …
book
JavaScript from Beginner to Professional
Start your journey towards becoming a JavaScript developer with the help of more than 100 fun …