Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
“Forms are static” – “No, they aren't”
Search
Markus H
June 02, 2015
Technology
1
9.3k
“Forms are static” – “No, they aren't”
My talk from DjangoCon Europe 2015 in Cardiff, Wales
Markus H
June 02, 2015
Tweet
Share
More Decks by Markus H
See All by Markus H
🐍 ❤️ 🦀 — Python loves Rust
markush
0
180
Knock! Knock! Who's There?
markush
0
50
An Introduction To Kubernetes ☸
markush
0
72
Writing Safe Database Migrations (DjangoCon Europe 2021)
markush
0
13k
A Pony On The Move: How Migrations Work In Django 🐎
markush
0
12k
All Hands on Deck — Handling Security Issues
markush
0
13k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
41
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
170
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
13k
Other Decks in Technology
See All in Technology
社内アプリで Cloudflare D1を プロダクト運用してみた体験談(Tokyo)
haochenx
0
130
require(ESM)とECMAScript仕様
uhyo
4
1k
Max out Local LLM in Challenging Environments
sashimimochi
2
200
高専で制御を、大学でセンシングを学び、次は脳みそ
satoshirobatofujimoto
0
120
Handling focus in 2024
tahia910
0
430
Android Target SDK 35 (Android 15) 対応の概要
akkie76
0
170
ルーターでプレゼンする
puhitaku
1
3.4k
Building a RAG-poweredAI chat appwith Python and VS Code
pamelafox
0
170
止まらないLinuxシステムを構築する_高信頼性クラスタ入門
koedoyoshida
3
2.3k
DX企業CTOとして考える技術への向き合い方
shoheitai
0
100
R3のコードから見る実践LINQ実装最適化・コンカレントプログラミング実例
neuecc
3
3.3k
.NET Profiler in 2024.
kkamegawa
2
2.2k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
21
3.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
660
120k
Optimizing for Happiness
mojombo
370
69k
Designing the Hi-DPI Web
ddemaree
276
33k
Rails Girls Zürich Keynote
gr2m
91
13k
Raft: Consensus for Rubyists
vanstee
133
6.3k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
Building Better People: How to give real-time feedback that sticks.
wjessup
356
18k
StorybookのUI Testing Handbookを読んだ
zakiyama
13
4.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
Transcript
“Forms are static” – “No, they aren't”
Hi, I’m Markus Holtermann • Django Core Developer • CS
MSc Student @m_holtermann • github.com/MarkusH • markusholtermann.eu
Forms are static
What does “static” even mean?
What about request dependent forms?
They are static too!
What are non-static forms then?
Why do you need them?
How does that work?
def modelform_factory(model, …): attrs = { ‘fields’: fields_for_model(model), ‘model’: model,
} Meta = type(str('Meta'), (object,), attrs) class_attrs = {‘Meta’: Meta} class_name = model.__name__ + str('Form') return type( class_name, ModelForm, class_attrs )
Wait! Aren’t they still static?
type(name, bases, attrs) rocks!
django-dynamic-forms http://django-dynamic-forms.rtfd.org
Actions FormModel Name URLs Name FormFieldModel Options Label … …
belongs to
@formmodel_action('Send to admins') def send_admins(form_model, form, request): # label →
value mapped_data = form.get_mapped_data() # construct message message = render_to_string( 'dynamic_forms/email.txt', { 'form': form_model, 'data': mapped_data}) # send data via mail mail_admins( “New form submission”, message )
@dynamic_form_field class IntegerField(BaseDynamicFormField): cls = 'django.forms.EmailField' display_label = 'Email' class
Meta: # attribute = [type, default, class] max_value = [int, None, forms.IntegerField] min_value = [int, None, forms.IntegerField]
None
None
None
django-dynamic-forms http://django-dynamic-forms.rtfd.org
Thank You! @m_holtermann • github.com/MarkusH • markusholtermann.eu