Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
“Forms are static” – “No, they aren't”
Markus H
June 02, 2015
Technology
1
7.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
97
Knock! Knock! Who's There?
markush
0
42
An Introduction To Kubernetes ☸
markush
0
61
Writing Safe Database Migrations (DjangoCon Europe 2021)
markush
0
11k
A Pony On The Move: How Migrations Work In Django 🐎
markush
0
10k
All Hands on Deck — Handling Security Issues
markush
0
11k
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon UK 2019)
markush
0
35
Logging Rethought 2: The Actions of Frank Taylor Jr. (PyCon Australia 2019)
markush
1
150
Logging Rethought 2: The Actions of Frank Taylor Jr. (DjangoCon Europe 2019)
markush
0
11k
Other Decks in Technology
See All in Technology
Oktaの管理者権限を適切に移譲してみた
shimosyan
2
220
マネーフォワードクラウドを支える事業者基盤
machisuke
0
160
ステート管理を超えるRecoil運用の考え方
uhyo
7
5.1k
MoT/コネヒト/Kanmu が語るプロダクト開発xデータ分析 - 分析から機械学習システムの開発まで一人で複数ロールを担う大変さ
masatakashiwagi
2
450
アジャイルな組織改善〜手法とマインドセット〜
ishige
7
5.2k
Amazon Forecast を使って売上予測をしてみた
tomuro
0
290
Cloudflare Workersで動くOG画像生成器
aiji42
1
430
GraphQLスキーマ設計の勘所
yukukotani
26
5.7k
聴覚障害のある大学生チームによる臆さない発言環境の形成
hayato_ukuk
0
1.7k
データエンジニアを助けてくれるFivetranとSnowflakeの仕様&機能のご紹介
sagara
0
410
私見「UNIXの考え方」/20230124-kameda-unix-phylosophy
opelab
0
130
2年で10→70人へ! スタートアップの 情報セキュリティ課題と施策
miekobayashi
1
170
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Statistics for Hackers
jakevdp
784
210k
Git: the NoSQL Database
bkeepers
PRO
418
60k
The Brand Is Dead. Long Live the Brand.
mthomps
48
2.9k
Bootstrapping a Software Product
garrettdimon
299
110k
From Idea to $5000 a Month in 5 Months
shpigford
374
44k
Teambox: Starting and Learning
jrom
124
7.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Art, The Web, and Tiny UX
lynnandtonic
284
18k
We Have a Design System, Now What?
morganepeng
37
5.9k
The Power of CSS Pseudo Elements
geoffreycrofte
52
4.3k
How To Stay Up To Date on Web Technology
chriscoyier
779
250k
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