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.6k
“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
190
Knock! Knock! Who's There?
markush
0
58
An Introduction To Kubernetes ☸
markush
0
76
Writing Safe Database Migrations (DjangoCon Europe 2021)
markush
0
14k
A Pony On The Move: How Migrations Work In Django 🐎
markush
0
13k
All Hands on Deck — Handling Security Issues
markush
0
13k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
48
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
180
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
13k
Other Decks in Technology
See All in Technology
宇宙ベンチャーにおける最近の情シス取り組みについて
axelmizu
0
110
20241220_S3 tablesの使い方を検証してみた
handy
4
640
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
170
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
2
110
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
230
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
200
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
Work as an App Engineer
lycorp_recruit_jp
0
100
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
210
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
360
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
290
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
99
Visualization
eitanlees
146
15k
Become a Pro
speakerdeck
PRO
26
5k
How STYLIGHT went responsive
nonsquared
95
5.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Music & Morning Musume
bryan
46
6.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Designing Experiences People Love
moore
138
23k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
A Tale of Four Properties
chriscoyier
157
23k
Fireside Chat
paigeccino
34
3.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
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