The document summarizes an upcoming talk by Daniel Greenfeld and Miguel Araujo on advanced Django form usage. It introduces the speakers and their backgrounds. It previews that the talk will cover fundamentals of good form patterns, calling forms in a cleaner way, handling file uploads simply, and using ModelForms. The talk aims to provide many technical tips to write forms with less code and complexity.
An advanced forms presentation given with Miguel Araujo (marajop) at DjangoCon 2011. The transcript and slides is aimed at getting into Django Core, and Jacob Kaplan-Moss has stated this is his plan.
O artigo defende que o respeito ao meio ambiente é essencial para a preservação do planeta. O autor argumenta que tanto grandes empresas quanto agricultores precisam respeitar mais a natureza e parar de usar tantos agrotóxicos. Além disso, o mercado de seguros deve incentivar mais as empresas a adotarem práticas sustentáveis e de preservação ambiental.
Find the all-new Hyundai Tucson in Salisbury at your top rated MD Hyundai dealer. Pohanka Hyundai of Salisbury has the new Hyundai Tucson you're looking for at the best prices and with the best financing you need. Visit us today!
This document provides an overview of server-side development concepts like functions, conditionals, and loops. It discusses keywords in programming languages that have special meanings like if, else, and, or. It provides an example of a function that uses conditionals. It outlines the rules for pair programming and test-driven development that will be used during code challenges. It assigns a challenge to write basic calculator functions using tests and handle errors without crashes. It concludes with questions for reflection on the process.
This document discusses Python and the Django web framework. It introduces Python and its uses at companies like Google. It then discusses installing and using Django, including using PyPI to install Django with easy_install, Django's model-view-controller architecture and features like object-relational mapping, templates and RSS/Atom feeds. It demonstrates starting a Django project and app and running initial migrations.
An advanced forms presentation given with Miguel Araujo (marajop) at DjangoCon 2011. The transcript and slides is aimed at getting into Django Core, and Jacob Kaplan-Moss has stated this is his plan.
O artigo defende que o respeito ao meio ambiente é essencial para a preservação do planeta. O autor argumenta que tanto grandes empresas quanto agricultores precisam respeitar mais a natureza e parar de usar tantos agrotóxicos. Além disso, o mercado de seguros deve incentivar mais as empresas a adotarem práticas sustentáveis e de preservação ambiental.
Find the all-new Hyundai Tucson in Salisbury at your top rated MD Hyundai dealer. Pohanka Hyundai of Salisbury has the new Hyundai Tucson you're looking for at the best prices and with the best financing you need. Visit us today!
This document provides an overview of server-side development concepts like functions, conditionals, and loops. It discusses keywords in programming languages that have special meanings like if, else, and, or. It provides an example of a function that uses conditionals. It outlines the rules for pair programming and test-driven development that will be used during code challenges. It assigns a challenge to write basic calculator functions using tests and handle errors without crashes. It concludes with questions for reflection on the process.
This document discusses Python and the Django web framework. It introduces Python and its uses at companies like Google. It then discusses installing and using Django, including using PyPI to install Django with easy_install, Django's model-view-controller architecture and features like object-relational mapping, templates and RSS/Atom feeds. It demonstrates starting a Django project and app and running initial migrations.
Django Package Thunderdome by Audrey Roy & Daniel GreenfeldAudrey Roy
What makes a package useful? What is it about certain packages that makes them must-haves for any project?
We’ll go over topics like: purpose, structure, docs, tests, availability on PyPI and Github/Bitbucket, activity, and more.
We will visit some of the most useful grid categories on djangopackages.com and highlight our top package picks, showing examples of what makes the top packages so great and what could use improvement.
Exploring push server options for Django. My presentation for Python User Group meetup, March 2018.
Some images borrowed from https://blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django.
This document discusses common Go programming mistakes and how to avoid them. It addresses issues with pointers like nil pointer dereferences and using optional types instead. Goroutines in loops are also covered, emphasizing the need to cancel contexts to avoid leaks. Other topics include differences between nil and typed nil, avoiding the default HTTP client, and establishing patterns through research to prevent implicit behavior from causing errors.
The document discusses developing with the Django web framework. It covers installing Django, creating projects and apps, defining models, views, templates, and urls. It also describes Django's MTV pattern, generic views, built-in template tags and filters, contrib modules, and resources for learning more about Django.
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itRyan Weaver
The document discusses the benefits of Drupal 8 over Drupal 7. Drupal 8 embraces modern PHP standards and libraries, allowing for easier code sharing, improved quality, and new possibilities. Key benefits include leveraging libraries like Symfony, Twig and others with no development effort, improved developer experience through object oriented code and standards, and the ability to more easily create new types of applications and distributions. Drupal 8 innovates away from outdated Drupal 7 technologies and practices to build a stronger, more interoperable community.
We Want YOU! Contributing to the Django CommunityMarcel Chastain
Contribute to the communities surrounding Open Source software like Django, Python, Github libraries easily - we need all the help we can get! In person, over the internet - it's easy!
This document discusses Perl 5 meta programming and provides examples of how to implement meta programming in Perl 5. It describes techniques like string eval, modifying the symbol table and typeglobs, using AUTOLOAD, Package::Stash, B:: modules, Class::Inspector, Class::Method::Modifiers, and Moo to get and set information about classes and define/modify methods and packages at runtime. It emphasizes writing tests and solving problems with existing modules when possible.
Presenting at the Microsoft Devs HK Meetup on 13 June, 2018
Code for presentation: https://github.com/sadukie/IntroToPyForCSharpDevs
Azure Notebook for presentation:
https://notebooks.azure.com/cletechconsulting/libraries/introtopyforcsharpdevs
This document summarizes the history and future plans for optimizations to the Pharo virtual machine (VM). It discusses past improvements like Spur in Pharo 5 that provided 1.8x faster performance. Pharo 6 focused on compaction and minor optimizations. Future work in Pharo 7 could include an incremental garbage collector and optimizations from the Sista just-in-time compiler that aim to provide 1.5-5x faster performance. The goals are to balance program readability and performance.
Why you should use Django in your next project.Eyad Toma
The document promotes using Django, an open-source web framework, for upcoming projects. It highlights that Django includes common components like object-relational mapping, user authentication and caching out of the box, but these features are optional and can be replaced. The document also notes that Django can be easily extended through thousands of third-party plug-ins and has a large global user base, including in the MENA region. In summary, it pitches Django as the best Python web framework that is fully-featured yet flexible.
This document provides an introduction to the Padrino web framework. It begins with an overview of the speaker and background on various web frameworks like Rails, Sinatra, and Padrino. It then discusses features of Sinatra like being a microframework and how Padrino combines aspects of both Sinatra and Rails by providing a full-stack solution with components like generators and a project structure similar to Rails. Sample code demonstrations compare starting a new Rails and Padrino project.
python full stack course in hyderabad...sowmyavibhin
Empower your career with our Python Full Stack Course in Hyderabad. Gain hands-on experience, industry recognition, and job placement assistance for a thriving journey in full-stack development.
python full stack course in hyderabad...sowmyavibhin
Empower your career with our Python Full Stack Course in Hyderabad. Gain hands-on experience, industry recognition, and job placement assistance for a thriving journey in full-stack development.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
5th LF Energy Power Grid Model Meet-up SlidesDanBrown980551
5th Power Grid Model Meet-up
It is with great pleasure that we extend to you an invitation to the 5th Power Grid Model Meet-up, scheduled for 6th June 2024. This event will adopt a hybrid format, allowing participants to join us either through an online Mircosoft Teams session or in person at TU/e located at Den Dolech 2, Eindhoven, Netherlands. The meet-up will be hosted by Eindhoven University of Technology (TU/e), a research university specializing in engineering science & technology.
Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
What to expect
For the upcoming meetup we are organizing, we have an exciting lineup of activities planned:
-Insightful presentations covering two practical applications of the Power Grid Model.
-An update on the latest advancements in Power Grid -Model technology during the first and second quarters of 2024.
-An interactive brainstorming session to discuss and propose new feature requests.
-An opportunity to connect with fellow Power Grid Model enthusiasts and users.
A Comprehensive Guide to DeFi Development Services in 2024Intelisync
DeFi represents a paradigm shift in the financial industry. Instead of relying on traditional, centralized institutions like banks, DeFi leverages blockchain technology to create a decentralized network of financial services. This means that financial transactions can occur directly between parties, without intermediaries, using smart contracts on platforms like Ethereum.
In 2024, we are witnessing an explosion of new DeFi projects and protocols, each pushing the boundaries of what’s possible in finance.
In summary, DeFi in 2024 is not just a trend; it’s a revolution that democratizes finance, enhances security and transparency, and fosters continuous innovation. As we proceed through this presentation, we'll explore the various components and services of DeFi in detail, shedding light on how they are transforming the financial landscape.
At Intelisync, we specialize in providing comprehensive DeFi development services tailored to meet the unique needs of our clients. From smart contract development to dApp creation and security audits, we ensure that your DeFi project is built with innovation, security, and scalability in mind. Trust Intelisync to guide you through the intricate landscape of decentralized finance and unlock the full potential of blockchain technology.
Ready to take your DeFi project to the next level? Partner with Intelisync for expert DeFi development services today!
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
Dive into the realm of operating systems (OS) with Pravash Chandra Das, a seasoned Digital Forensic Analyst, as your guide. 🚀 This comprehensive presentation illuminates the core concepts, types, and evolution of OS, essential for understanding modern computing landscapes.
Beginning with the foundational definition, Das clarifies the pivotal role of OS as system software orchestrating hardware resources, software applications, and user interactions. Through succinct descriptions, he delineates the diverse types of OS, from single-user, single-task environments like early MS-DOS iterations, to multi-user, multi-tasking systems exemplified by modern Linux distributions.
Crucial components like the kernel and shell are dissected, highlighting their indispensable functions in resource management and user interface interaction. Das elucidates how the kernel acts as the central nervous system, orchestrating process scheduling, memory allocation, and device management. Meanwhile, the shell serves as the gateway for user commands, bridging the gap between human input and machine execution. 💻
The narrative then shifts to a captivating exploration of prominent desktop OSs, Windows, macOS, and Linux. Windows, with its globally ubiquitous presence and user-friendly interface, emerges as a cornerstone in personal computing history. macOS, lauded for its sleek design and seamless integration with Apple's ecosystem, stands as a beacon of stability and creativity. Linux, an open-source marvel, offers unparalleled flexibility and security, revolutionizing the computing landscape. 🖥️
Moving to the realm of mobile devices, Das unravels the dominance of Android and iOS. Android's open-source ethos fosters a vibrant ecosystem of customization and innovation, while iOS boasts a seamless user experience and robust security infrastructure. Meanwhile, discontinued platforms like Symbian and Palm OS evoke nostalgia for their pioneering roles in the smartphone revolution.
The journey concludes with a reflection on the ever-evolving landscape of OS, underscored by the emergence of real-time operating systems (RTOS) and the persistent quest for innovation and efficiency. As technology continues to shape our world, understanding the foundations and evolution of operating systems remains paramount. Join Pravash Chandra Das on this illuminating journey through the heart of computing. 🌟
Your One-Stop Shop for Python Success: Top 10 US Python Development Providersakankshawande
Simplify your search for a reliable Python development partner! This list presents the top 10 trusted US providers offering comprehensive Python development services, ensuring your project's success from conception to completion.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Generating privacy-protected synthetic data using Secludy and MilvusZilliz
During this demo, the founders of Secludy will demonstrate how their system utilizes Milvus to store and manipulate embeddings for generating privacy-protected synthetic data. Their approach not only maintains the confidentiality of the original data but also enhances the utility and scalability of LLMs under privacy constraints. Attendees, including machine learning engineers, data scientists, and data managers, will witness first-hand how Secludy's integration with Milvus empowers organizations to harness the power of LLMs securely and efficiently.
Django Package Thunderdome by Audrey Roy & Daniel GreenfeldAudrey Roy
What makes a package useful? What is it about certain packages that makes them must-haves for any project?
We’ll go over topics like: purpose, structure, docs, tests, availability on PyPI and Github/Bitbucket, activity, and more.
We will visit some of the most useful grid categories on djangopackages.com and highlight our top package picks, showing examples of what makes the top packages so great and what could use improvement.
Exploring push server options for Django. My presentation for Python User Group meetup, March 2018.
Some images borrowed from https://blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django.
This document discusses common Go programming mistakes and how to avoid them. It addresses issues with pointers like nil pointer dereferences and using optional types instead. Goroutines in loops are also covered, emphasizing the need to cancel contexts to avoid leaks. Other topics include differences between nil and typed nil, avoiding the default HTTP client, and establishing patterns through research to prevent implicit behavior from causing errors.
The document discusses developing with the Django web framework. It covers installing Django, creating projects and apps, defining models, views, templates, and urls. It also describes Django's MTV pattern, generic views, built-in template tags and filters, contrib modules, and resources for learning more about Django.
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itRyan Weaver
The document discusses the benefits of Drupal 8 over Drupal 7. Drupal 8 embraces modern PHP standards and libraries, allowing for easier code sharing, improved quality, and new possibilities. Key benefits include leveraging libraries like Symfony, Twig and others with no development effort, improved developer experience through object oriented code and standards, and the ability to more easily create new types of applications and distributions. Drupal 8 innovates away from outdated Drupal 7 technologies and practices to build a stronger, more interoperable community.
We Want YOU! Contributing to the Django CommunityMarcel Chastain
Contribute to the communities surrounding Open Source software like Django, Python, Github libraries easily - we need all the help we can get! In person, over the internet - it's easy!
This document discusses Perl 5 meta programming and provides examples of how to implement meta programming in Perl 5. It describes techniques like string eval, modifying the symbol table and typeglobs, using AUTOLOAD, Package::Stash, B:: modules, Class::Inspector, Class::Method::Modifiers, and Moo to get and set information about classes and define/modify methods and packages at runtime. It emphasizes writing tests and solving problems with existing modules when possible.
Presenting at the Microsoft Devs HK Meetup on 13 June, 2018
Code for presentation: https://github.com/sadukie/IntroToPyForCSharpDevs
Azure Notebook for presentation:
https://notebooks.azure.com/cletechconsulting/libraries/introtopyforcsharpdevs
This document summarizes the history and future plans for optimizations to the Pharo virtual machine (VM). It discusses past improvements like Spur in Pharo 5 that provided 1.8x faster performance. Pharo 6 focused on compaction and minor optimizations. Future work in Pharo 7 could include an incremental garbage collector and optimizations from the Sista just-in-time compiler that aim to provide 1.5-5x faster performance. The goals are to balance program readability and performance.
Why you should use Django in your next project.Eyad Toma
The document promotes using Django, an open-source web framework, for upcoming projects. It highlights that Django includes common components like object-relational mapping, user authentication and caching out of the box, but these features are optional and can be replaced. The document also notes that Django can be easily extended through thousands of third-party plug-ins and has a large global user base, including in the MENA region. In summary, it pitches Django as the best Python web framework that is fully-featured yet flexible.
This document provides an introduction to the Padrino web framework. It begins with an overview of the speaker and background on various web frameworks like Rails, Sinatra, and Padrino. It then discusses features of Sinatra like being a microframework and how Padrino combines aspects of both Sinatra and Rails by providing a full-stack solution with components like generators and a project structure similar to Rails. Sample code demonstrations compare starting a new Rails and Padrino project.
python full stack course in hyderabad...sowmyavibhin
Empower your career with our Python Full Stack Course in Hyderabad. Gain hands-on experience, industry recognition, and job placement assistance for a thriving journey in full-stack development.
python full stack course in hyderabad...sowmyavibhin
Empower your career with our Python Full Stack Course in Hyderabad. Gain hands-on experience, industry recognition, and job placement assistance for a thriving journey in full-stack development.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
5th LF Energy Power Grid Model Meet-up SlidesDanBrown980551
5th Power Grid Model Meet-up
It is with great pleasure that we extend to you an invitation to the 5th Power Grid Model Meet-up, scheduled for 6th June 2024. This event will adopt a hybrid format, allowing participants to join us either through an online Mircosoft Teams session or in person at TU/e located at Den Dolech 2, Eindhoven, Netherlands. The meet-up will be hosted by Eindhoven University of Technology (TU/e), a research university specializing in engineering science & technology.
Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
What to expect
For the upcoming meetup we are organizing, we have an exciting lineup of activities planned:
-Insightful presentations covering two practical applications of the Power Grid Model.
-An update on the latest advancements in Power Grid -Model technology during the first and second quarters of 2024.
-An interactive brainstorming session to discuss and propose new feature requests.
-An opportunity to connect with fellow Power Grid Model enthusiasts and users.
A Comprehensive Guide to DeFi Development Services in 2024Intelisync
DeFi represents a paradigm shift in the financial industry. Instead of relying on traditional, centralized institutions like banks, DeFi leverages blockchain technology to create a decentralized network of financial services. This means that financial transactions can occur directly between parties, without intermediaries, using smart contracts on platforms like Ethereum.
In 2024, we are witnessing an explosion of new DeFi projects and protocols, each pushing the boundaries of what’s possible in finance.
In summary, DeFi in 2024 is not just a trend; it’s a revolution that democratizes finance, enhances security and transparency, and fosters continuous innovation. As we proceed through this presentation, we'll explore the various components and services of DeFi in detail, shedding light on how they are transforming the financial landscape.
At Intelisync, we specialize in providing comprehensive DeFi development services tailored to meet the unique needs of our clients. From smart contract development to dApp creation and security audits, we ensure that your DeFi project is built with innovation, security, and scalability in mind. Trust Intelisync to guide you through the intricate landscape of decentralized finance and unlock the full potential of blockchain technology.
Ready to take your DeFi project to the next level? Partner with Intelisync for expert DeFi development services today!
Taking AI to the Next Level in Manufacturing.pdfssuserfac0301
Read Taking AI to the Next Level in Manufacturing to gain insights on AI adoption in the manufacturing industry, such as:
1. How quickly AI is being implemented in manufacturing.
2. Which barriers stand in the way of AI adoption.
3. How data quality and governance form the backbone of AI.
4. Organizational processes and structures that may inhibit effective AI adoption.
6. Ideas and approaches to help build your organization's AI strategy.
Dive into the realm of operating systems (OS) with Pravash Chandra Das, a seasoned Digital Forensic Analyst, as your guide. 🚀 This comprehensive presentation illuminates the core concepts, types, and evolution of OS, essential for understanding modern computing landscapes.
Beginning with the foundational definition, Das clarifies the pivotal role of OS as system software orchestrating hardware resources, software applications, and user interactions. Through succinct descriptions, he delineates the diverse types of OS, from single-user, single-task environments like early MS-DOS iterations, to multi-user, multi-tasking systems exemplified by modern Linux distributions.
Crucial components like the kernel and shell are dissected, highlighting their indispensable functions in resource management and user interface interaction. Das elucidates how the kernel acts as the central nervous system, orchestrating process scheduling, memory allocation, and device management. Meanwhile, the shell serves as the gateway for user commands, bridging the gap between human input and machine execution. 💻
The narrative then shifts to a captivating exploration of prominent desktop OSs, Windows, macOS, and Linux. Windows, with its globally ubiquitous presence and user-friendly interface, emerges as a cornerstone in personal computing history. macOS, lauded for its sleek design and seamless integration with Apple's ecosystem, stands as a beacon of stability and creativity. Linux, an open-source marvel, offers unparalleled flexibility and security, revolutionizing the computing landscape. 🖥️
Moving to the realm of mobile devices, Das unravels the dominance of Android and iOS. Android's open-source ethos fosters a vibrant ecosystem of customization and innovation, while iOS boasts a seamless user experience and robust security infrastructure. Meanwhile, discontinued platforms like Symbian and Palm OS evoke nostalgia for their pioneering roles in the smartphone revolution.
The journey concludes with a reflection on the ever-evolving landscape of OS, underscored by the emergence of real-time operating systems (RTOS) and the persistent quest for innovation and efficiency. As technology continues to shape our world, understanding the foundations and evolution of operating systems remains paramount. Join Pravash Chandra Das on this illuminating journey through the heart of computing. 🌟
Your One-Stop Shop for Python Success: Top 10 US Python Development Providersakankshawande
Simplify your search for a reliable Python development partner! This list presents the top 10 trusted US providers offering comprehensive Python development services, ensuring your project's success from conception to completion.
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slackshyamraj55
Discover the seamless integration of RPA (Robotic Process Automation), COMPOSER, and APM with AWS IDP enhanced with Slack notifications. Explore how these technologies converge to streamline workflows, optimize performance, and ensure secure access, all while leveraging the power of AWS IDP and real-time communication via Slack notifications.
Generating privacy-protected synthetic data using Secludy and MilvusZilliz
During this demo, the founders of Secludy will demonstrate how their system utilizes Milvus to store and manipulate embeddings for generating privacy-protected synthetic data. Their approach not only maintains the confidentiality of the original data but also enhances the utility and scalability of LLMs under privacy constraints. Attendees, including machine learning engineers, data scientists, and data managers, will witness first-hand how Secludy's integration with Milvus empowers organizations to harness the power of LLMs securely and efficiently.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Trusted Execution Environment for Decentralized Process MiningLucaBarbaro3
Presentation of the paper "Trusted Execution Environment for Decentralized Process Mining" given during the CAiSE 2024 Conference in Cyprus on June 7, 2024.
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on integration of Salesforce with Bonterra Impact Management.
Interested in deploying an integration with Salesforce for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
1. Advanced Django
Form Usage
by Daniel Greenfeld and Miguel Araujo
2. Daniel Greenfeld
• pydanny
• Python & Django developer for
Cartwheel Web / RevSys
• Founded django-uni-form
• Does Capoeira
• Lives in Los Angeles with his
Advanced Django Form Usage
http://www.flickr.com/photos/pydanny/4442245488/
Fiancé, Audrey Roy (audreyr)
@pydanny / @maraujop
2
3. Miguel Araujo
• maraujop
• Freelance Python developer
• Co-lead of django-uni-form
• Does Muay Thai
• Lives in Madrid with his
amazing girlfiend who does
Advanced Django Form Usage
aerospace for a living
@pydanny / @maraujop
• http://maraujop.github.com/
3
5. Tons of technical content
• We probably won’t have time for questions
Advanced Django Form Usage
@pydanny / @maraujop
4
6. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
Advanced Django Form Usage
@pydanny / @maraujop
4
7. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
• Too much content in the abstract
Advanced Django Form Usage
@pydanny / @maraujop
4
8. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
• Too much content in the abstract
• Special thanks to:
Advanced Django Form Usage
@pydanny / @maraujop
4
9. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
• Too much content in the abstract
• Special thanks to:
• Brian Rosner
Advanced Django Form Usage
@pydanny / @maraujop
4
10. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
• Too much content in the abstract
• Special thanks to:
• Brian Rosner
Advanced Django Form Usage
• James Tauber
@pydanny / @maraujop
4
11. Tons of technical content
• We probably won’t have time for questions
• Slides will be posted right after the talk
• Too much content in the abstract
• Special thanks to:
• Brian Rosner
Advanced Django Form Usage
• James Tauber
@pydanny / @maraujop
• Frank Wiles
4
12. Advanced Django Form Usage
@pydanny / @maraujop
Good Form Patterns
Fundamentals of
5
13. Fundamentals of
Good Form Patterns
• Zen of Python still applies
Advanced Django Form Usage
@pydanny / @maraujop
5
14. Fundamentals of
Good Form Patterns
• Zen of Python still applies
• import this
Advanced Django Form Usage
@pydanny / @maraujop
5
15. Fundamentals of
Good Form Patterns
• Zen of Python still applies
• import this
• Spartan programming als0 is important
Advanced Django Form Usage
@pydanny / @maraujop
5
20. Calling forms the easy way
• Smaller, cleaner code makes our lives better
Advanced Django Form Usage
@pydanny / @maraujop
9
21. Calling forms the easy way
• Smaller, cleaner code makes our lives better
• Line 5 of the Zen of Python
Advanced Django Form Usage
@pydanny / @maraujop
9
22. Calling forms the easy way
• Smaller, cleaner code makes our lives better
• Line 5 of the Zen of Python
• Flat is better than nested.
Advanced Django Form Usage
@pydanny / @maraujop
9
23. Calling forms the easy way
• Smaller, cleaner code makes our lives better
• Line 5 of the Zen of Python
• Flat is better than nested.
• Aim for minimal boilerplate
Advanced Django Form Usage
@pydanny / @maraujop
9
24. Calling forms the easy way
• Smaller, cleaner code makes our lives better
• Line 5 of the Zen of Python
• Flat is better than nested.
• Aim for minimal boilerplate
Advanced Django Form Usage
• So you can focus on your business logic
@pydanny / @maraujop
9
26. A Basic Django Form
class MyForm(forms.Form):
name = forms.CharField(_('Name'), required=True)
Advanced Django Form Usage
@pydanny / @maraujop
11
27. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST':
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/')
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
12
28. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST': Form #1
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/')
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
12
29. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST': Form #1
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/') Form #2
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
12
30. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST': Form #1
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/') Form #2
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
Only 1 nested if, but real code
@pydanny / @maraujop
gets much more complex
12
31. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST': Form #1
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/') Form #2
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
Only 1 nested if, but real code
@pydanny / @maraujop
gets much more complex Custom business
goes here
12
32. Standard views.py
def my_view(request, template_name='myapp/my_form.html'):
if request.method == 'POST': Form #1
form = MyForm(request.POST) # Form #1!
if form.is_valid(): # nested if!
do_x()
return redirect('/') Form #2
else:
form = MyForm() # Form #2!
return render(request, template_name, {'form': form})
Advanced Django Form Usage
Only 1 nested if, but real code
@pydanny / @maraujop
gets much more complex Custom business
goes here
12
33. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
Custom business
goes here
13
34. Single form
Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
Custom business
goes here
13
35. Single form
Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
Advanced Django Form Usage
If no request.POST,
@pydanny / @maraujop
Custom business then instantiated with None
goes here
13
36. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
Advanced Django Form Usage
@pydanny / @maraujop
14
37. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
• 6 lines of code instead of 9
Advanced Django Form Usage
@pydanny / @maraujop
14
38. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
• 6 lines of code instead of 9
Advanced Django Form Usage
• 33.3333333333% less code to debug
@pydanny / @maraujop
14
39. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
• 6 lines of code instead of 9
Advanced Django Form Usage
• 33.3333333333% less code to debug
@pydanny / @maraujop
• One form instantiation
14
40. Easy views.py
def my_view(request, template_name='myapp/my_form.html'):
# sticks in a POST or renders empty form
form = MyForm(request.POST or None)
if form.is_valid():
do_x()
return redirect('home')
return render(request, template_name, {'form': form})
• 6 lines of code instead of 9
Advanced Django Form Usage
• 33.3333333333% less code to debug
@pydanny / @maraujop
• One form instantiation
• less conditionals == less edge case insanity
14
49. pydanny made
up statistics
• 91% of all Django projects use ModelForms
Advanced Django Form Usage
@pydanny / @maraujop
18
50. pydanny made
up statistics
• 91% of all Django projects use ModelForms
• 80% ModelForms require trivial logic
Advanced Django Form Usage
@pydanny / @maraujop
18
51. pydanny made
up statistics
• 91% of all Django projects use ModelForms
• 80% ModelForms require trivial logic
• 20% ModelForms require complicated logic
Advanced Django Form Usage
@pydanny / @maraujop
18
52. pydanny made
up statistics
• 91% of all Django projects use ModelForms
• 80% ModelForms require trivial logic
• 20% ModelForms require complicated logic
Advanced Django Form Usage
@pydanny / @maraujop
Let’s try and make that easy
18
53. A Basic ModelForm
class MyModelForm(forms.Form):
class Meta:
model = MyModel
fields = ['name']
Advanced Django Form Usage
@pydanny / @maraujop
19
54. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
20
55. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel) Form #1
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
20
56. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel) Form #1
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home') Form #2
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
20
57. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel) Form #1
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home') Form #2
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Only 1 nested if, but real code
Advanced Django Form Usage
gets much more complex
@pydanny / @maraujop
20
58. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel) Form #1
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home') Form #2
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Only 1 nested if, but real code
Advanced Django Form Usage
gets much more complex
@pydanny / @maraujop
Custom business
goes here
20
59. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel) Form #1
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home') Form #2
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Only 1 nested if, but real code
Advanced Django Form Usage
gets much more complex
@pydanny / @maraujop
Custom business
goes here
20
60. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
21
61. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
• 12 lines of code
Advanced Django Form Usage
@pydanny / @maraujop
21
62. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
• 12 lines of code
Advanced Django Form Usage
• Nested conditionals
@pydanny / @maraujop
21
63. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
• 12 lines of code
Advanced Django Form Usage
• Nested conditionals
@pydanny / @maraujop
• What if we have to handle 3 different submit buttons?
21
64. Classic views.py for ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/my_model_form.html'):
# I wouldn't call the variable model, because it's an instance of a model, it's confusing
mymodel = get_object_or_404(MyModel, slug=slug)
if request.method == 'POST':
form = MyForm(request, instance=mymodel)
if form.is_valid():
mymodel = form.save()
mymodel.day_shown = datetime.datetime.now() # Do any extra model stuff here
mymodel.save()
return redirect('home')
else:
form = MyForm(instance=mymodel)
return render(request, template_name, {'form': form, 'model': mymodel})
• 12 lines of code
Advanced Django Form Usage
• Nested conditionals
@pydanny / @maraujop
• What if we have to handle 3 different submit buttons?
• Watch out for edge case insanity!
21
66. easy views.py + ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/
my_model_form.html'):
mymodel = get_object_or_404(MyModel, slug=slug)
form = MyModelForm(request.POST or None, instance=mymodel)
Single form
if form.is_valid():
mymodel = form.save()
mymodel.edited_at_djangocon = True
mymodel.save()
return redirect('home')
return render(request, template_name, {'form': form, 'mymodel': mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
22
67. easy views.py + ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/
my_model_form.html'):
mymodel = get_object_or_404(MyModel, slug=slug)
form = MyModelForm(request.POST or None, instance=mymodel)
Single form
if form.is_valid():
mymodel = form.save()
mymodel.edited_at_djangocon = True
mymodel.save()
return redirect('home')
return render(request, template_name, {'form': form, 'mymodel': mymodel})
Advanced Django Form Usage
Custom business
@pydanny / @maraujop
goes here
22
68. easy views.py + ModelForm
def my_model_edit(request, slug=slug, template_name='myapp/
my_model_form.html'):
mymodel = get_object_or_404(MyModel, slug=slug)
form = MyModelForm(request.POST or None, instance=mymodel)
Single form
if form.is_valid():
mymodel = form.save()
mymodel.edited_at_djangocon = True
mymodel.save()
return redirect('home')
return render(request, template_name, {'form': form, 'mymodel': mymodel})
If no request.POST,
then instantiated with None
Advanced Django Form Usage
Custom business
@pydanny / @maraujop
goes here So this will fail validation!
22
74. add views.py + ModelForm
def my_model_add(request, template_name='myapp/my_model_form.html'):
form = MyModelForm(request.POST or None)
if form.is_valid():
mymodel = form.save() No need for an
mymodel.added_at_djangocon = True
mymodel.save() instance here
return redirect('home')
return render(request,template_name,{'form': form,'mymodel':mymodel})
Advanced Django Form Usage
@pydanny / @maraujop
25
75. add views.py + ModelForm
def my_model_add(request, template_name='myapp/my_model_form.html'):
form = MyModelForm(request.POST or None)
if form.is_valid():
mymodel = form.save() No need for an
mymodel.added_at_djangocon = True
mymodel.save() instance here
return redirect('home')
return render(request,template_name,{'form': form,'mymodel':mymodel})
Advanced Django Form Usage
This creates the
@pydanny / @maraujop
model instance.
25
76. I can make it smaller!
def my_model_tiny_add(request,template_name='myapp/my_model_form.html'):
form = MyModelForm(request.POST or None)
if form.is_valid():
form.save() Not setting defaults here
return redirect('home')
return render(request,template_name,{'form':form,'mymodel':mymodel})
Advanced Django Form Usage
Good practice: Use model field defaults rather
@pydanny / @maraujop
than doing it in your views.
26
78. Advanced Django Form Usage
@pydanny / @maraujop
Please don’t manually
test your forms
28
79. Please don’t manually
test your forms
• This isn’t a testing talk but...
Advanced Django Form Usage
@pydanny / @maraujop
28
80. Please don’t manually
test your forms
• This isn’t a testing talk but...
• Forms are the number one thing to test
Advanced Django Form Usage
@pydanny / @maraujop
28
81. Please don’t manually
test your forms
• This isn’t a testing talk but...
• Forms are the number one thing to test
• Don’t skip on testing them
Advanced Django Form Usage
@pydanny / @maraujop
28
82. Please don’t manually
test your forms
• This isn’t a testing talk but...
• Forms are the number one thing to test
• Don’t skip on testing them
• Edge case insanity is the thing to fear
Advanced Django Form Usage
@pydanny / @maraujop
28
88. non-required to required
• Your model fields are non-required
• but you want the form fields to be required
Advanced Django Form Usage
@pydanny / @maraujop
31
89. A basic Django models.py
class MyModel(models.Model):
name = models.CharField(_('Name'), max_length=50, blank=True, null=True)
age = models.IntegerField(_('Age in years'), blank=True, null=True)
profession = models.CharField(_('Profession'),
max_length=100, blank=True, null=True)
bio = models.TextField(_('Bio'), blank=True, null=True)
Advanced Django Form Usage
@pydanny / @maraujop
32
90. Classic forms.py overload
class MyModelTooMuchTypingForm(forms.ModelForm):
""" I've done this and it sucks
hard to debug and too much duplication
"""
name = forms.CharField(_('Name'), max_length=50, required=True)
age = forms.IntegerField(_('Age in years'), required=True)
profession = forms.CharField(_('Profession'), required=True)
bio = forms.TextField(_('Bio'), required=True)
class Meta:
model = MyModel
Advanced Django Form Usage
@pydanny / @maraujop
33
91. Classic forms.py overload
class MyModelTooMuchTypingForm(forms.ModelForm):
""" I've done this and it sucks
hard to debug and too much duplication
"""
name = forms.CharField(_('Name'), max_length=50, required=True)
age = forms.IntegerField(_('Age in years'), required=True)
profession = forms.CharField(_('Profession'), required=True)
bio = forms.TextField(_('Bio'), required=True)
class Meta:
model = MyModel
Advanced Django Form Usage
@pydanny / @maraujop
class MyModel(models.Model):
name = models.CharField(_('Name'), max_length=50, blank=True, null=True)
age = models.IntegerField(_('Age in years'), blank=True, null=True)
profession = models.CharField(_('Profession'), max_length=100, blank=True, null=True)
bio = models.TextField(_('Bio'), blank=True, null=True)
33
92. Classic forms.py overload
class MyModelTooMuchTypingForm(forms.ModelForm):
""" I've done this and it sucks
hard to debug and too much duplication
"""
name = forms.CharField(_('Name'), max_length=50, required=True)
age = forms.IntegerField(_('Age in years'), required=True)
profession = forms.CharField(_('Profession'), required=True)
bio = forms.TextField(_('Bio'), required=True)
class Meta: Nearly duplicated code
model = MyModel
Advanced Django Form Usage
@pydanny / @maraujop
class MyModel(models.Model):
name = models.CharField(_('Name'), max_length=50, blank=True, null=True)
age = models.IntegerField(_('Age in years'), blank=True, null=True)
profession = models.CharField(_('Profession'), max_length=100, blank=True, null=True)
bio = models.TextField(_('Bio'), blank=True, null=True)
33
93. Classic forms.py overload
class MyModelTooMuchTypingForm(forms.ModelForm):
""" I've done this and it sucks
hard to debug and too much duplication
"""
name = forms.CharField(_('Name'), max_length=50, required=True)
age = forms.IntegerField(_('Age in years'), required=True)
profession = forms.CharField(_('Profession'), required=True)
bio = forms.TextField(_('Bio'), required=True)
class Meta: Nearly duplicated code
model = MyModel
Advanced Django Form Usage
@pydanny / @maraujop
class MyModel(models.Model):
name = models.CharField(_('Name'), max_length=50, blank=True, null=True)
age = models.IntegerField(_('Age in years'), blank=True, null=True)
profession = models.CharField(_('Profession'), max_length=100, blank=True, null=True)
bio = models.TextField(_('Bio'), blank=True, null=True)
33
94. Better forms.py overload
class MyModelForm(forms.ModelForm):
""" Much better and you are extending, not copy/pasting """
def __init__(self):
super(MyModelForm, self).__init__(*args, **kwargs)
self.fields['name'].required = True
self.fields['age'].required = True
self.fields['profession'].required = True
self.fields['profession'].help_text = _("Hi professor")
Advanced Django Form Usage
class Meta:
Fields are in a dict-like object
@pydanny / @maraujop
model = MyModel
34
95. Try it with inheritance!
class BaseEmailForm(forms.Form):
email = forms.EmailField(_('Email'))
confirm_email = forms.EmailField(_('Email 2'))
class ContactForm(BaseEmailForm):
message = forms.CharField(_('Message'))
def __init__(self):
super(ContactForm, self).__init__(*args, **kwargs)
self.fields['confirm_email'].label = _('Confirm your email')
self.fields['confirm_email'].description = _('We want to be absolutely
certain we have your correct email address.')
Advanced Django Form Usage
@pydanny / @maraujop
35
97. Dynamically adding fields
to a form
def my_view(request, template_name='myapp/my_model_form.html'):
form = MyModelForm(request.POST or None)
# Let's add a field on the go, needs to be done before validating it
form.fields['favorite_color'] = forms.ChoiceField(
label = "Which is your favorite color from these?",
choices = (('blue', 'blue'), ('red', 'red'), ('green', 'green')),
widget = forms.RadioSelect,
required = True,
)
if form.is_valid():
# Let's get user's favorite color,
# you can do whatever you want with it
favorite_color = form.cleaned_data['favorite_color']
Advanced Django Form Usage
form.save()
@pydanny / @maraujop
return redirect('home')
return render(request, template_name, {'form': form})
37
98. Dynamically adding fields
to a form
def my_view(request, template_name='myapp/my_model_form.html'): Form dictionary
form = MyModelForm(request.POST or None) of fields
# Let's add a field on the go, needs to be done before validating it
form.fields['favorite_color'] = forms.ChoiceField(
label = "Which is your favorite color from these?",
choices = (('blue', 'blue'), ('red', 'red'), ('green', 'green')),
widget = forms.RadioSelect,
required = True,
)
if form.is_valid():
# Let's get user's favorite color,
# you can do whatever you want with it
favorite_color = form.cleaned_data['favorite_color']
Advanced Django Form Usage
form.save()
@pydanny / @maraujop
return redirect('home')
return render(request, template_name, {'form': form})
37
99. Dynamically adding fields
to a form
def my_view(request, template_name='myapp/my_model_form.html'): Form dictionary
form = MyModelForm(request.POST or None) of fields
# Let's add a field on the go, needs to be done before validating it
form.fields['favorite_color'] = forms.ChoiceField(
label = "Which is your favorite color from these?",
choices = (('blue', 'blue'), ('red', 'red'), ('green', 'green')),
widget = forms.RadioSelect,
required = True,
)
Fields have to be added
before the form.is_valid
if form.is_valid():
# Let's get user's favorite color,
# you can do whatever you want with it
favorite_color = form.cleaned_data['favorite_color']
method is checked.
Advanced Django Form Usage
form.save()
@pydanny / @maraujop
return redirect('home')
return render(request, template_name, {'form': form})
37
100. Can’t we just pass in a
list of fields into a form
from a view?
101. Constructor overrides forms.py
class MyModelForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
extra = kwargs.pop('extra')
super(UserCreationForm, self).__init__(*args, **kwargs)
for i, question in enumerate(extra):
self.fields['custom_%s' % i] = forms.CharField(label=question)
def extra_fields(self): looping over
"""
Returns a tuple (question, answer)
‘extra’ iterable
Advanced Django Form Usage
"""
@pydanny / @maraujop
for name, value in self.cleaned_data.items():
if name.startswith('custom_'):
yield (self.fields[name].label, value)
39
102. Constructor overrides views.py
def my_view(request, template_name='myapp/my_model_form.html'):
form = MyModelForm(request.POST or None,
extra=["What's your pet's name?"])
Passing in a list
if form.is_valid():
# We can gather extra fields data doing
of form field
for (question, answer) in form.extra_fields(): titles
save_answer(request, question, answer)
form.save()
return redirect('home')
Advanced Django Form Usage
@pydanny / @maraujop
return render(request, template_name, {'form': form})
40
104. formsets.py
class ItemFormSet(BaseFormSet):
def __init__(self, numberItems, *args, **kwargs):
super(ItemFormSet, self).__init__(*args, **kwargs)
self.numberItems = numberItems
def clean(self):
# Don't bother validating the formset
# unless each form is valid on its own
if any(self.errors):
return
for form in self.forms:
Advanced Django Form Usage
if not form.cleaned_data['your_choice'] == 'mod_wsgi':
@pydanny / @maraujop
raise ValidationError(u'mod_wsgi is the way to go!')
42
105. formsets.py
class ItemFormSet(BaseFormSet):
def __init__(self, numberItems, *args, **kwargs):
super(ItemFormSet, self).__init__(*args, **kwargs)
self.numberItems = numberItems
def clean(self):
Forms must have
# Don't bother validating the formset
‘your_choice’ field that
# unless each form is valid on its own
if any(self.errors):
return only accepts “mod_wsgi”
for form in self.forms:
Advanced Django Form Usage
if not form.cleaned_data['your_choice'] == 'mod_wsgi':
@pydanny / @maraujop
raise ValidationError(u'mod_wsgi is the way to go!')
42
108. Things I want python
to describe in forms
• Different fieldsets within the same form
• Various buttons
• submit
• reset
Advanced Django Form Usage
@pydanny / @maraujop
45
110. Programmatic layouts
class ExampleForm(forms.Form):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'first arg is the legend of the fieldset',
'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color',
'favorite_food',
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
111. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'first arg is the legend of the fieldset',
'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color',
'favorite_food',
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
112. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form): FormHelper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(
'first arg is the legend of the fieldset',
'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color',
'favorite_food',
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
113. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form): FormHelper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout( Layout
Fieldset(
'first arg is the legend of the fieldset',
'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color',
'favorite_food',
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
114. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form): FormHelper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout( Layout
Fieldset(
'first arg is the legend of the fieldset',
Fieldset 'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color',
'favorite_food',
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
115. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form): FormHelper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout( Layout
Fieldset(
'first arg is the legend of the fieldset',
Fieldset 'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
'favorite_color', Button
'favorite_food',
Holder
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
116. Programmatic layouts
from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Fieldset, ButtonHolder, Layout
class ExampleForm(forms.Form): FormHelper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.layout = Layout( Layout
Fieldset(
'first arg is the legend of the fieldset',
Fieldset 'like_website',
'favorite_number',
),
Fieldset(
'second arg is the legend of the fieldset',
Button 'favorite_color', Button
'favorite_food',
Holder
Advanced Django Form Usage
)
@pydanny / @maraujop
ButtonHolder(
Submit('submit', 'Submit', css_class='button white')
)
)
return super(ExampleForm, 47
self).__init__(*args, **kwargs)
117. renders as divs
{% load uni_form_tags %}
{% uni_form my_form my_form.helper %}
Renders the HTML form
with buttons and everything
wrapped in a fieldset.
Advanced Django Form Usage
@pydanny / @maraujop
48
121. django-floppyforms
• by Bruno Renie @brutasse
• HTML5 Widgets
• Fully customizable templates
• Plays nice with django-uni-form
Advanced Django Form Usage
@pydanny / @maraujop
52
122. Easy to use!
import floppyforms as forms
class ExampleForm(forms.Form):
username = forms.CharField(
label='',
widget = forms.TextInput(
attrs={'placeholder': '@johndoe'},
),
)
• Django’s widget parameter attrs expects a dictionary
Advanced Django Form Usage
@pydanny / @maraujop
• Replaces the normal widgets with HTML5 ones
53
123. Customizable widgets
import floppyforms as forms
class OtherEmailInput(forms.EmailInput):
template_name = 'path/to/other_email.html'
forms.py
<input type="email"
name="{{ name }}"
id="{{ attrs.id }}"
Advanced Django Form Usage
placeholder="john@example.com"
@pydanny / @maraujop
{% if value %}value="{{ value }}"{% endif %}>
path/to/other_email.html
54
129. What we are getting in 1.4
• Form rendering will use templates instead
of HTML in Python
Advanced Django Form Usage
@pydanny / @maraujop
59
130. What we are getting in 1.4
• Form rendering will use templates instead
of HTML in Python
• Template based widgets
Advanced Django Form Usage
@pydanny / @maraujop
59
131. What we are getting in 1.4
• Form rendering will use templates instead
of HTML in Python
• Template based widgets
• Template based form layout
Advanced Django Form Usage
@pydanny / @maraujop
59
132. Advanced Django Form Usage
@pydanny / @maraujop
forms refactor and
django-uni-form
60
133. forms refactor and
django-uni-form
• forms refactor layout “lives” in templates
Advanced Django Form Usage
@pydanny / @maraujop
60
134. forms refactor and
django-uni-form
• forms refactor layout “lives” in templates
• django-uni-form layout “lives” in python
Advanced Django Form Usage
@pydanny / @maraujop
60
135. forms refactor and
django-uni-form
• forms refactor layout “lives” in templates
• django-uni-form layout “lives” in python
• Different approaches, same objective
Advanced Django Form Usage
@pydanny / @maraujop
60
137. The docs on custom fields
“Its only requirements are that it implement
a clean() method and that its __init__()
method accept the core arguments
mentioned above (required, label, initial,
widget, help_text).”
Advanced Django Form Usage
@pydanny / @maraujop
62
138. The docs on custom fields
“Its only requirements are that it implement
a clean() method and that its __init__()
method accept the core arguments
mentioned above (required, label, initial,
widget, help_text).”
Advanced Django Form Usage
The docs seem to be wrong
@pydanny / @maraujop
62
139. How it really works
You don’t need to implement “clean”
You do need to implement:
• required
• widget • error_messages
• label • show_hidden_initial
Advanced Django Form Usage
• help_text • validators
@pydanny / @maraujop
• initial • localize
63
140. How the heck then do I
actually add a custom
form field?!?
141. Advanced Django Form Usage
@pydanny / @maraujop
validation work?
How does form
65
142. fields.py
class AMarkField(forms.Field):
widget = TextInput
default_error_messages = {
'not_an_a': _(u'you can only input A here! damn!'),
}
def __init__(self, **kwargs):
super(AMarkField, self).__init__(**kwargs)
def to_python(self, value):
if value in validators.EMPTY_VALUES:
Only accepts upper
return None
case A as input
Advanced Django Form Usage
if value != 'A':
@pydanny / @maraujop
raise ValidationError(self.error_messages['not_an_a'])
return value
66
143. Not DRY
class MyModelForm(forms.ModelForm):
mark = CharField()
def clean_mark(self):
mark_value = self.cleaned_data['mark']
if mark_value is not None or mark_value.upper() != 'A':
raise ValidationError(_(u'Only input A here!'))
return mark_value
class ExampleForm(forms.Form):
mark = CharField()
def clean_mark(self):
Advanced Django Form Usage
mark_value = self.cleaned_data['mark']
@pydanny / @maraujop
if mark_value is not None or mark_value.upper() != 'A':
raise ValidationError(_(u'Only input A here!'))
return mark_value
67
145. The JSON field
class JSONField(forms.Field):
default_error_messages = {
'invalid': 'This is not valid JSON string'
}
def to_python(self, value):
if value in validators.EMPTY_VALUES:
return None
try:
json = simplejson.loads(value)
Advanced Django Form Usage
except ValueError:
@pydanny / @maraujop
raise ValidationError(self.error_messages['invalid'])
return json
69
146. I want a custom
widget that handles
multiple widgets
147. widgets.py
from django.forms.extras.widgets import MultiWidget
class AddressWidget(MultiWidget):
def __init__(self, attrs=None):
widgets = (TextInput, TextInput)
super(AddressWidget, self).__init__(widgets, attrs)
def decompress(self, value):
"""
If called, value is a string should return a list
"""
Advanced Django Form Usage
if value:
# parse stuff and return a list
@pydanny / @maraujop
return value.split()
return [None, None]
71
148. widgets.py
from django.forms.extras.widgets import MultiWidget
class AddressWidget(MultiWidget): Two TextInput
def __init__(self, attrs=None): widgets!!!
widgets = (TextInput, TextInput)
super(AddressWidget, self).__init__(widgets, attrs)
def decompress(self, value):
"""
If called, value is a string should return a list
"""
Advanced Django Form Usage
if value:
# parse stuff and return a list
@pydanny / @maraujop
return value.split()
return [None, None]
71
149. widgets.py
from django.forms.extras.widgets import MultiWidget
class AddressWidget(MultiWidget): Two TextInput
def __init__(self, attrs=None): widgets!!!
widgets = (TextInput, TextInput)
super(AddressWidget, self).__init__(widgets, attrs)
def decompress(self, value):
"""
If called, value is a string should return a list
"""
Advanced Django Form Usage
if value:
# parse stuff and return a list
@pydanny / @maraujop
return value.split()
Called when a form with
return [None, None] MultiWidget is passed initial
or instance values
71
150. fields.py
class AddressField(forms.Field):
self.widget = AddressWidget
def to_python(self, value):
# Already gets a Python list
return value
isinstance(["921 SW Sixth Avenue", "Portland"], list)
Advanced Django Form Usage
@pydanny / @maraujop
72
151. fields.py
class AddressField(forms.Field):
self.widget = AddressWidget
def to_python(self, value):
# Already gets a Python list
return value
isinstance(["921 SW Sixth Avenue", "Portland"], list)
class ExampleForm(object):
forms.CharField(widget=AddressWidget)
Advanced Django Form Usage
isinstance("921 SW Sixth Avenue, Portland", str)
@pydanny / @maraujop
72
154. MultiValue, MultiWidget Field
class AlternativeAddressField(forms.MultiValueField):
widget = AddressWidget
def __init__(self, *args, **kwargs):
fields = (forms.CharField(), forms.CharField())
super(AlternativeAddressField, self).__init__(fields,
*args, **kwargs)
def compress(self, data_list):
return data_list
• Clean does not work in the standard way
Advanced Django Form Usage
@pydanny / @maraujop
74
155. MultiValue, MultiWidget Field
class AlternativeAddressField(forms.MultiValueField):
widget = AddressWidget
def __init__(self, *args, **kwargs):
fields = (forms.CharField(), forms.CharField())
super(AlternativeAddressField, self).__init__(fields,
*args, **kwargs)
def compress(self, data_list):
return data_list
• Clean does not work in the standard way
• Every field validated with its corresponding widget value
Advanced Django Form Usage
@pydanny / @maraujop
74
156. MultiValue, MultiWidget Field
class AlternativeAddressField(forms.MultiValueField):
widget = AddressWidget
def __init__(self, *args, **kwargs):
fields = (forms.CharField(), forms.CharField())
super(AlternativeAddressField, self).__init__(fields,
*args, **kwargs)
def compress(self, data_list):
return data_list
• Clean does not work in the standard way
• Every field validated with its corresponding widget value
Advanced Django Form Usage
•
@pydanny / @maraujop
Beware! run_validator does run but validate is called
74
157. MultiValue, MultiWidget Field
class AlternativeAddressField(forms.MultiValueField):
widget = AddressWidget
def __init__(self, *args, **kwargs):
fields = (forms.CharField(), forms.CharField())
super(AlternativeAddressField, self).__init__(fields,
*args, **kwargs)
def compress(self, data_list):
return data_list
• Clean does not work in the standard way
• Every field validated with its corresponding widget value
Advanced Django Form Usage
•
@pydanny / @maraujop
Beware! run_validator does run but validate is called
Django Ticket #14184
74
160. Advanced Django Form Usage
@pydanny / @maraujop
Custom Widget Output
So Easy!
77
161. def render(self, name, value, attrs=None):
Custom Widget Output
# HTML to be added to the output
widget_labels = [
'<label for="id_%s">Address: </label>',
'<label for="id_%s">Number: </label>'
]
if self.is_localized:
for widget in self.widgets:
widget.is_localized = self.is_localized
# value is a list of values, each corresponding to a widget
So Easy!
# in self.widgets.
if not isinstance(value, list):
value = self.decompress(value)
output = []
final_attrs = self.build_attrs(attrs)
id_ = final_attrs.get('id', None)
for i, widget in enumerate(self.widgets):
try:
widget_value = value[i]
except IndexError:
widget_value = None
if id_:
Advanced Django Form Usage
final_attrs = dict(final_attrs, id='%s_%s' % (id_, i))
# Adding labels
@pydanny / @maraujop
output.append(widget_labels[i] % ('%s_%s' % (name, i)))
output.append(widget.render(name + '_%s' % i, widget_value, final_attrs))
return mark_safe(self.format_output(output))
77
162. def render(self, name, value, attrs=None):
Custom Widget Output
# HTML to be added to the output
widget_labels = [
'<label for="id_%s">Address: </label>',
'<label for="id_%s">Number: </label>'
]
if self.is_localized:
for widget in self.widgets:
widget.is_localized = self.is_localized
# value is a list of values, each corresponding to a widget
So Easy!
# in self.widgets.
if not isinstance(value, list):
value = self.decompress(value)
output = []
final_attrs = self.build_attrs(attrs)
id_ = final_attrs.get('id', None)
for i, widget in enumerate(self.widgets):
try:
widget_value = value[i]
except IndexError:
widget_value = None
if id_:
Advanced Django Form Usage
final_attrs = dict(final_attrs, id='%s_%s' % (id_, i))
# Adding labels
@pydanny / @maraujop
output.append(widget_labels[i] % ('%s_%s' % (name, i)))
output.append(widget.render(name + '_%s' % i, widget_value, final_attrs))
return mark_safe(self.format_output(output))
77
164. Problems with Custom
Widget Output
• Overring render means indepth knowledge
• Hard to do custom output with built-in widgets
• You can’t call super.render and customize easily
• Templates? Open Ticket #15667
Advanced Django Form Usage
@pydanny / @maraujop
79
166. Problems with Custom
Widget Output
• Oldest ticket in Django is related to forms
(#23)
• ComboField is broken
• Validators are thought to validate simple values
Advanced Django Form Usage
because of the way run_validators is coded
@pydanny / @maraujop
81
167. HTML5 tickets
• Ticket #16304
• Ticket #16630
• Just use django-floppyforms
Advanced Django Form Usage
@pydanny / @maraujop
82
168. Validators
• Imagine you have an input that get a list of emails seperated
by spaces
• Your widget returns: [“a@example.com”, “b@example.com”]
• You want to run validators on all of them
•
Advanced Django Form Usage
There is an EmailValidator
@pydanny / @maraujop
83
169. MultiValidator
class MultiValidator(object):
def __init__(self, validators):
self.validators = validators
def __call__(self, data_list):
errors = []
for value in data_list:
for validator in self.validators:
try:
validator(value)
except ValidationError, e:
Advanced Django Form Usage
if hasattr(e, 'code'):
errors.append("FiXED MESSAGE")
@pydanny / @maraujop
raise ValidationError(errors)
84
170. Amazing stuff
• Ticket #27 reported by Adrian Holovaty
• Single form field for multiple database fields
Advanced Django Form Usage
@pydanny / @maraujop
85
173. This has been
incredible
• We’ve just scratched the surface
Advanced Django Form Usage
@pydanny / @maraujop
87
174. This has been
incredible
• We’ve just scratched the surface
• Keep your code clean - or you’ll regret it
Advanced Django Form Usage
@pydanny / @maraujop
87
Editor's Notes
D\n
M\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\nIf you can reduce your line count from 10 to 2 and make it more obvious, that is good\nThis is why so many people prefer things like Python over Java\n
D\nYou want to have shallow code with as little if statements as possible\nOtherwise you create lots of hard to test edge cases\n
D\n
D\n
D\n
D\n
D\n
M\nShow me the code!\n
D\n
D\nassuming we have from forms import MyForm\nIn real life this can get big, complex, and nasty\n
D\nassuming we have from forms import MyForm\nIn real life this can get big, complex, and nasty\n
D\nassuming we have from forms import MyForm\nIn real life this can get big, complex, and nasty\n
D\nassuming we have from forms import MyForm\nIn real life this can get big, complex, and nasty\n
D\nassuming we have from forms import MyForm\nIn real life this can get big, complex, and nasty\n
D\n
D\n
D\n
D\n
D\n
D\n
D \nMy fiancee, Audrey Roy, said my example needs to handle file uploads. How do we do that?\n
M\n
M\n
M\n
M\n
M\nHey Danny, don&#x2019;t 91% of real Django projects use ModelForms?\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\nHey Miguel, how do I make this work when adding data?\n
M\n
M\n
M\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
M\nAny other tricks?\n
D\n
D\n
D\n
D\n
D\n
D Fields are in a dictionary! We should remember this fact!\n
D\n
D\n\n
M\nDidn&#x2019;t you just show that fields are stored in a dict in the form? Why not just add another field that way?\n
M\nDidn&#x2019;t you just show that fields are stored in a dict in the form? Why not just add another field that way?\n
D\n\n
M - Let's override form constructor to wrap the logic of adding fields on the go\n\n
M - Let's override form constructor to wrap the logic of adding fields on the go\n\n
D\n\n
M\n
M\n
M\n\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n
D\n\n
M\n
M\n
M\n
D\n\n
M\n\n
M\nBecause both DUF and DFF do things in a clean, non-magical way - they just work together. \nNamespaces and clean code beat smart hackery any day.\n
M\nTell me what is coming down the road\n
D\n
D\n
D\n
D\nIt&#x2019;s okay that there are different objects\n
D\nIt&#x2019;s okay that there are different objects\n
D\nIt&#x2019;s okay that there are different objects\n
M\n\n
D\n\n
D\n
D\n\n
M\n
M Of course you could do the same with a regular CharField using form validationclean_<fieldname> method, but...\n
M - Duplicated code. So do a custom form field instead of duplicating code everywhere\nYes, you could solve this with form inheritance, but what if the inheritance chain gets too long?\n
M\n\n
D This field returns an already JSON validated Python list when accessing cleaned_data\n
D\n\n
M We are using MultiWidget.\n
M We are using MultiWidget.\n
M The difference is that you can get fancier with validation on the list than the string\n
D\n\n
M You need to implement compress\nIt would be nice that fields were also an attribute in the parent class.\n
M You need to implement compress\nIt would be nice that fields were also an attribute in the parent class.\n
M You need to implement compress\nIt would be nice that fields were also an attribute in the parent class.\n
M You need to implement compress\nIt would be nice that fields were also an attribute in the parent class.\n
M\n
M\n\n
D - You are going to love how easy this is! Ready?\n
D - You are going to love how easy this is! Ready?\n
D\n\n
M\n
M\n\n
M\n
M\n
M\n
M * You can raise a ValidationError with a code. * You can raise a ValidationError with a list of messages. * You could raise a ValidationError on the first email that fails, but error will be less helpful. * Hard to customize, no error_messages, Do this in an upper layer, rewrite run_validators\n