Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Help a cause by building a donation system
Search
Dražen Lučanin
April 29, 2017
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Help a cause by building a donation system
DjangoGirls Vienna April 2017 lightning talk
Dražen Lučanin
April 29, 2017
Transcript
11 slides
Help a cause by building a donation system Dražen Lučanin
@metakermit
• Helping a young green party run for local elections
in Zagreb • Inspiration for applying your Django skills :) Background
Functionality • Donation form with field validation • Talking to
an external API to generate a scannable 2D barcode • Email the payment information • Admin interface ◦ confirming payments ◦ exporting reports
Model class Donation(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) submitted_time =
models.DateTimeField(auto_now_add=True) OIB = models.CharField(max_length=11, validators=[oib_validator]) name = models.CharField(max_length=30, validators=[utf8_30_validator]) email = models.EmailField() street = models.CharField(max_length=27, validators=[utf8_27_validator]) place = models.CharField(max_length=27, validators=[utf8_27_validator]) phone = models.CharField(max_length=30, blank=True) # optional physical_person = models.BooleanField(default=True) amount = models.PositiveIntegerField() paid = models.BooleanField(default=False) barcode = models.ImageField(blank=True, upload_to='barcodes/%Y/%m/%d') invoice_image = models.ImageField(blank=True, upload_to='invoices/%Y/%m/%d')
None
Talking to an external API – requests hub3_args = {
"renderer": "image", "data": { "amount": self.amount, "sender": { "name": self.name, }, "receiver": { "iban": settings.DONATIONS_RECIPIENT_IBAN, } } } response = requests.post( 'https://hub3.bigfish.software/api/v1/barcode', json=hub3_args )
We even got a bit fancy using PIL… img =
Image.open(blank_invoice_path) draw = ImageDraw.Draw(img) draw.text((749, 132), settings.DONATIONS_RECIPIENT_IBAN, text_color, font=font)
Popular payment services • Stripe • BrainTree
Email the payment info – django-anymail + Mailgun msg =
EmailMultiAlternatives( subject="Uplatnica za donaciju", body=text_content, to=[f"{donation.name} <{donation.email}>"] ) msg.attach('uplatnica.jpg', invoice_file.getvalue(), 'image/jpeg') msg.attach('barcode.png', barcode_file.getvalue(), 'image/png') # Send it: msg.send()
And it works… • http://www.zagrebjenas.hr/doniraj/
Thanks! • Now go build your own project :)
More Decks by Dražen Lučanin
See All by Dražen Lučanin
Digitalisation for Citizen Empowerment
metakermit
0
70
Crowdfunding Python (& other IT) projects
metakermit
0
140
Pokreni posao: Freelancing
metakermit
1
240
Efficiently deploying Django
metakermit
1
230
Home office on a budget
metakermit
0
150
How to start freelancing
metakermit
0
270
From freelancing to incorporating
metakermit
0
260
Running a company as an e-Resident in Croatia
metakermit
0
740
CSS Animations
metakermit
0
410
Other Decks in Programming
See All in Programming
Crash Auto Pipelines
veronikapj
1
450
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
マルチプロダクトSaaSの アプリ一覧を速くする——複数プロダクトにまたがる「権限行脚」を減らすまで #techramen26conf
mktakuya
1
200
AIコーディングをセッションで終わらせない: PHPライブラリ開発におけるコンテキスト承継設計
ickx
0
110
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
6.2k
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
400
protojson における文字化けの扱い
kazuki1023
0
460
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
170
Math.sumPreciseから学ぶ、ECMAScript仕様の数値の種類
syumai
0
130
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
520
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
500
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.8k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
620
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Building Applications with DynamoDB
mza
96
7.3k
[SF Ruby Conf 2025] Rails X
palkan
3
1.6k
A designer walks into a library…
pauljervisheath
211
25k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
540
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.9k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
390
Discover your Explorer Soul
emna__ayadi
2
1.3k
Google's AI Overviews - The New Search
badams
0
1.7k