Presentation on how to chat with PDF using ChatGPT code interpreter
那些年,我用 Django Admin 接的案子
1. Big Data, Better Decision
Michelle Leu @flywindy
PyCon Taiwan 2016 #PyConTW2016
那些年,
我⽤ Django Admin 接的案⼦
2.
3. Once upon the time…
Facial bed –
The story has just begun
• A chain of SPA (10+ branches)
• Paper work -> Computer record
4. Why use Django Admin?
Django Admin - the automatic admin interface
• Django 1.9 - big updates after 8 years
• No requirements of design
• It’s all about records
18. Before overwriting
• date_hierarchy
• DateField or DateTimeField
# account/admin.py
class AccountAdmin(admin.ModelAdmin):
date_hierarchy = 'start_date'
19. Before overwriting
• empty_value_display
• New in Django 1.9
• The default value is - (a dash)
• format_html
• raw_id_fields
• Change into an Input widget for either a ForeignKey or
ManyToManyField
def colored_name(self):
return format_html('<span style="color: #{};">{} {}</span>',
self.color_code,
self.first_name,
self.last_name)
20. Before overwriting
• list_editable
• Any field in list_editable must also be in list_display. You can’t edit a field that’s not displayed!
• The same field can’t be listed in both list_editable and list_display_links – a field can’t be both a form
and a link.
# account/admin.py
class AccountAdmin(admin.ModelAdmin):
list_display = ('member_id', 'name', 'birthday', 'mobile')
list_display_links = ('member_id', 'name')
list_editable = ('birthday', 'mobile')
21. Renaming
• Model field - verbose_name
• Models - Meta class
• verbose_name
• verbose_name_plural
• App - AppConfig (Django 1.7+)
• A string representing an attribute on the ModelAdmin ex: member_id
• short_descripSon
23. Overwrite templates
1. Set up your projects admin template directories
• templates/admin/
2. To override an admin template for a specific app
• templates/admin/my_app/
3. Just overriding not replacing
• block
4. Templates which may be overridden per app or model
• app_index.html, change_form.htm, change_list.htm, deleteconfirmaSon.html,
object_history.html
5. Root and login templates – AdminSite
• login_template, logout_template, password_change_template…
24. How to customize JS and CSS
a. Overwrite base.html
b. Define assets in ModelAdmin (the Media class)
class ArScleAdmin(admin.ModelAdmin):
class Media:
css = {
"all": ("my_styles.css",)
}
js = ("my_code.js",)
27. Summary
When to use Django Admin
• Design
• write you view and tmeplate
• No design
• Django Admin package
• Customize your django admin
Next
• Python Web Meetup
28. PyCon Taiwan 2016 Talks
R0
Day 2 16:20 - 16:45
Write your own micro data
processing framework in python
CEO CTOGM
Django Girls Taipei
hLp://djangogirls.org/taipei
2016.06.04 BoF X PyLadies
2016.07.09 Django Girls Workshop #4
Day 3 10:30 – 10:55
Python 的 50 道陰影
Day 3 11:00 – 11:25
Analyzing Chinese Lyrics with
Python
29. THANK YOU
info@gliacloud.com / 886 2 2752 8851
Unit.3, 11F., No.48, Fuxing N.Rd., Zhongshan Dist., Taipei City 104, Taiwan