SlideShare a Scribd company logo
Michelle Leu
@flywindy
2014/02/11
WHO AND WHEN TO USE THE DJANGO ADMIN
When people ask, “What are the benefits of Django over other web frameworks?”
the admin is what usually comes to mind.
Who
•  It's Not for End Users
When
•  It’s usually not worth it to heavily customize the Django admin.
VIEWING STRING REPRESENTATIONS OF
OBJECTS
•  Implement the __unicode__ ()
#EXAMPLE 15.1
from django.db import models
class IceCreamBar(models.Model):
name = models.CharField(max_length=100)
shell = models.CharField(max_length=100)
filling = models.CharField(max_length=100)
has_stick = models.BooleanField(default=True)
def __unicode__(self):
return self.name
VIEWING STRING REPRESENTATIONS OF
OBJECTS
•  Implement the __unicode__ ()
>>> IceCreamBar.objects.all()
[<IceCreamBar: Vanilla Crisp>, <IceCreamBar: Mint Cookie Crunch>,
<IceCreamBar: Strawberry Pie>]
VIEWING STRING REPRESENTATIONS OF
OBJECTS
•  Use list_display
#EXAMPLE 15.3
from django.contrib import admin
from .models import IceCreamBar
class IceCreamBarAdmin(admin.ModelAdmin):
list_display = ("name", "shell", "filling”,)
admin.site.register(IceCreamBar, IceCreamBarAdmin)
VIEWING STRING REPRESENTATIONS OF
OBJECTS
•  Use list_display
VIEWING STRING REPRESENTATIONS OF
OBJECTS
•  search_fields
•  list_filter
•  date_hierarchy
•  ordering
ADDING CALLABLES TO MODELADMIN CLASSES
#EXAMPLE 15.4
from django.contrib import admin
from django.core.urlresolvers import reverse
from icecreambars.models import IceCreamBar
class IceCreamBarAdmin(admin.ModelAdmin):
list_display = ("name", "shell", "filling",)
readonly_fields = ("show_url",)
def show_url(self, instance):
url = reverse("ice_cream_bar_detail", kwargs={"pk": instance.pk})
response = """<a href="{0}">{0}</a>""".format(url)
return response
show_url.short_description = "Ice Cream Bar URL"
# Displays HTML tags
# Never set allow_tags to True against user submitted data!!!
show_url.allow_tags = True
admin.site.register(IceCreamBar, IceCreamBarAdmin)
ADDING CALLABLES TO MODELADMIN CLASSES
OTHER FRAMEWORKS
  Flask-admin
  plays nicely with various ORM's, including SQLAlchemy, MongoEngine,
pymongo and Peewee.
  file management interface
  redis client console
OTHER FRAMEWORKS
  Web2py
  Web-Based IDE: Create, modify, deploy and manage application from
anywhere using your browser. One web2py instance can run multiple web sites
using different databases.
DJANGO ADMIN PLUGIN
django-xadmin(by sshwsfc)
•  Drop-in replacement of Django admin
•  Twitter Bootstrap based UI with theme support
•  Extensible with plugin support
•  Better filter, date range, number range, etc.
•  Built-in data export with xls, csv, xml and json format
•  Dashboard page with widget support
•  In-site bookmarking
•  Full CRUD methods
•  Documentation: Chinese
http://demo.xadmin.io
DJANGO ADMIN PLUGIN
django-grappelli (by sehmaschine)
•  Clean and consistent look & feel
•  Related lookups with Autocompletes
•  Inline sortables with Drag & Drop
•  Compass-based CSS
• Integrated TinyMCE theme
• Customizable dashboard
• Improved collapsibles
• Unified jQuery-Plugins
• Compatible with django—filebrowser
DJANGO ADMIN PLUGIN
django-admin2 (by pydanny)
•  Rewrite of the Django Admin backend
•  Drop-in themes
•  Built-in RESTful API
•  (django-rest-framework)
django-admin-bootstrapped
•  Bootstrap theme
REFERENCE
  Django official doc: https://docs.djangoproject.com/en/dev/ref/contrib/admin/
  Django Book: http://django-book.readthedocs.org/en/latest/chapter06.html
  Flask-admin doc: https://flask-admin.readthedocs.org/en/latest/
  Flask-admin example: http://examples.flask-admin.org/
  django-xadmin: https://github.com/sshwsfc/django-xadmin
  django-grappelli: http://grappelliproject.com/
  Django Packages - Admin Interface:
https://www.djangopackages.com/grids/g/admin-interface/

More Related Content

What's hot (20)

PDF
Dexterity in the Wild
David Glick
 
PPTX
Django Architecture Introduction
Haiqi Chen
 
PDF
Efficient Rails Test-Driven Development - Week 6
Marakana Inc.
 
KEY
Jumpstart Django
ryates
 
PDF
Introduction To Django (Strange Loop 2011)
Jacob Kaplan-Moss
 
PDF
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
PPTX
Обзор автоматизации тестирования на JavaScript
COMAQA.BY
 
PPT
How to learn to build your own PHP framework
Dinh Pham
 
PDF
Building Web Sites that Work Everywhere
Doris Chen
 
PDF
A Dexterity Intro for Recovering Archetypes Addicts
David Glick
 
PDF
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
PDF
Building Pluggable Web Applications using Django
Lakshman Prasad
 
PDF
Javascript Test Automation Workshop (21.08.2014)
Deutsche Post
 
KEY
Introduction Django
Wade Austin
 
PPTX
End-to-end testing with geb
Jesús L. Domínguez Muriel
 
PDF
Odoo Experience 2018 - The Odoo JS Framework
ElínAnna Jónasdóttir
 
PDF
Django for mobile applications
Hassan Abid
 
KEY
Making Django and NoSQL Play Nice
Alex Gaynor
 
PDF
Introduction to Selenium and Ruby
Ynon Perek
 
PDF
Djangocon 2014 angular + django
Nina Zakharenko
 
Dexterity in the Wild
David Glick
 
Django Architecture Introduction
Haiqi Chen
 
Efficient Rails Test-Driven Development - Week 6
Marakana Inc.
 
Jumpstart Django
ryates
 
Introduction To Django (Strange Loop 2011)
Jacob Kaplan-Moss
 
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Обзор автоматизации тестирования на JavaScript
COMAQA.BY
 
How to learn to build your own PHP framework
Dinh Pham
 
Building Web Sites that Work Everywhere
Doris Chen
 
A Dexterity Intro for Recovering Archetypes Addicts
David Glick
 
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
Building Pluggable Web Applications using Django
Lakshman Prasad
 
Javascript Test Automation Workshop (21.08.2014)
Deutsche Post
 
Introduction Django
Wade Austin
 
End-to-end testing with geb
Jesús L. Domínguez Muriel
 
Odoo Experience 2018 - The Odoo JS Framework
ElínAnna Jónasdóttir
 
Django for mobile applications
Hassan Abid
 
Making Django and NoSQL Play Nice
Alex Gaynor
 
Introduction to Selenium and Ruby
Ynon Perek
 
Djangocon 2014 angular + django
Nina Zakharenko
 

Viewers also liked (20)

PDF
Django 實戰 - 自己的購物網站自己做
flywindy
 
PDF
Django workshop homework 3
flywindy
 
PDF
Two scoops of Django - Deployment
flywindy
 
PPTX
Two scoops of django Introduction
flywindy
 
PDF
Django best practices for logging and signals
flywindy
 
PDF
Django Third party packages
Andy Dai
 
PDF
Django admin
Petter Arvidsson
 
PDF
Boost your django admin with Grappelli
Andy Dai
 
PDF
Des cartes d'un autre monde - DjangoCong 2012
Makina Corpus
 
PDF
Pytables
gowell
 
PDF
Live Performance Effects
Tom Chen
 
PDF
Command line 初級寶典
Tom Chen
 
PDF
真蝦意外接到的Case
Tom Chen
 
PPS
Xmas
Tom Chen
 
PDF
Geotrek
Makina Corpus
 
PDF
Elasticsearch intro output
Tom Chen
 
PDF
AngularJS Sharing
Tom Chen
 
PDF
Django step0
永昇 陳
 
PPTX
Gitlab
Tom Chen
 
PDF
Best Practices for Front-End Django Developers
Christine Cheung
 
Django 實戰 - 自己的購物網站自己做
flywindy
 
Django workshop homework 3
flywindy
 
Two scoops of Django - Deployment
flywindy
 
Two scoops of django Introduction
flywindy
 
Django best practices for logging and signals
flywindy
 
Django Third party packages
Andy Dai
 
Django admin
Petter Arvidsson
 
Boost your django admin with Grappelli
Andy Dai
 
Des cartes d'un autre monde - DjangoCong 2012
Makina Corpus
 
Pytables
gowell
 
Live Performance Effects
Tom Chen
 
Command line 初級寶典
Tom Chen
 
真蝦意外接到的Case
Tom Chen
 
Xmas
Tom Chen
 
Geotrek
Makina Corpus
 
Elasticsearch intro output
Tom Chen
 
AngularJS Sharing
Tom Chen
 
Django step0
永昇 陳
 
Gitlab
Tom Chen
 
Best Practices for Front-End Django Developers
Christine Cheung
 
Ad

Similar to Working with the django admin (20)

PDF
Django
Mohamed Ramadan
 
PDF
Introduction to Django
Jagdeep Singh Malhi
 
PDF
django_introduction20141030
Kevin Wu
 
PDF
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
PDF
django
webuploader
 
PDF
Intro to Web Development Using Python and Django
Chariza Pladin
 
PDF
Django Overview
Brian Tol
 
PDF
Chapter 6 the django admin site
家璘 卓
 
PDF
Rapid web application development using django - Part (1)
Nishant Soni
 
PDF
Django
Narcisse Siewe
 
PDF
Download full ebook of Mastering Django Core Nigel George instant download pdf
ajiyalovelu
 
PPTX
Web development with django - Basics Presentation
Shrinath Shenoy
 
PPTX
Django crush course
Mohammed El Rafie Tarabay
 
ODP
Introduction to Django
colinkingswood
 
ODP
dJango
Bob Chao
 
PPTX
Django framework
TIB Academy
 
PPTX
Basic Python Django
Kaleem Ullah Mangrio
 
PPT
DJango
Sunil OS
 
PDF
You've done the Django Tutorial, what next?
Andy McKay
 
PDF
Introduction to Python and Django
solutionstreet
 
Introduction to Django
Jagdeep Singh Malhi
 
django_introduction20141030
Kevin Wu
 
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
django
webuploader
 
Intro to Web Development Using Python and Django
Chariza Pladin
 
Django Overview
Brian Tol
 
Chapter 6 the django admin site
家璘 卓
 
Rapid web application development using django - Part (1)
Nishant Soni
 
Download full ebook of Mastering Django Core Nigel George instant download pdf
ajiyalovelu
 
Web development with django - Basics Presentation
Shrinath Shenoy
 
Django crush course
Mohammed El Rafie Tarabay
 
Introduction to Django
colinkingswood
 
dJango
Bob Chao
 
Django framework
TIB Academy
 
Basic Python Django
Kaleem Ullah Mangrio
 
DJango
Sunil OS
 
You've done the Django Tutorial, what next?
Andy McKay
 
Introduction to Python and Django
solutionstreet
 
Ad

Recently uploaded (20)

PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 

Working with the django admin

  • 2. WHO AND WHEN TO USE THE DJANGO ADMIN When people ask, “What are the benefits of Django over other web frameworks?” the admin is what usually comes to mind. Who •  It's Not for End Users When •  It’s usually not worth it to heavily customize the Django admin.
  • 3. VIEWING STRING REPRESENTATIONS OF OBJECTS •  Implement the __unicode__ () #EXAMPLE 15.1 from django.db import models class IceCreamBar(models.Model): name = models.CharField(max_length=100) shell = models.CharField(max_length=100) filling = models.CharField(max_length=100) has_stick = models.BooleanField(default=True) def __unicode__(self): return self.name
  • 4. VIEWING STRING REPRESENTATIONS OF OBJECTS •  Implement the __unicode__ () >>> IceCreamBar.objects.all() [<IceCreamBar: Vanilla Crisp>, <IceCreamBar: Mint Cookie Crunch>, <IceCreamBar: Strawberry Pie>]
  • 5. VIEWING STRING REPRESENTATIONS OF OBJECTS •  Use list_display #EXAMPLE 15.3 from django.contrib import admin from .models import IceCreamBar class IceCreamBarAdmin(admin.ModelAdmin): list_display = ("name", "shell", "filling”,) admin.site.register(IceCreamBar, IceCreamBarAdmin)
  • 6. VIEWING STRING REPRESENTATIONS OF OBJECTS •  Use list_display
  • 7. VIEWING STRING REPRESENTATIONS OF OBJECTS •  search_fields •  list_filter •  date_hierarchy •  ordering
  • 8. ADDING CALLABLES TO MODELADMIN CLASSES #EXAMPLE 15.4 from django.contrib import admin from django.core.urlresolvers import reverse from icecreambars.models import IceCreamBar class IceCreamBarAdmin(admin.ModelAdmin): list_display = ("name", "shell", "filling",) readonly_fields = ("show_url",) def show_url(self, instance): url = reverse("ice_cream_bar_detail", kwargs={"pk": instance.pk}) response = """<a href="{0}">{0}</a>""".format(url) return response show_url.short_description = "Ice Cream Bar URL" # Displays HTML tags # Never set allow_tags to True against user submitted data!!! show_url.allow_tags = True admin.site.register(IceCreamBar, IceCreamBarAdmin)
  • 9. ADDING CALLABLES TO MODELADMIN CLASSES
  • 10. OTHER FRAMEWORKS   Flask-admin   plays nicely with various ORM's, including SQLAlchemy, MongoEngine, pymongo and Peewee.   file management interface   redis client console
  • 11. OTHER FRAMEWORKS   Web2py   Web-Based IDE: Create, modify, deploy and manage application from anywhere using your browser. One web2py instance can run multiple web sites using different databases.
  • 12. DJANGO ADMIN PLUGIN django-xadmin(by sshwsfc) •  Drop-in replacement of Django admin •  Twitter Bootstrap based UI with theme support •  Extensible with plugin support •  Better filter, date range, number range, etc. •  Built-in data export with xls, csv, xml and json format •  Dashboard page with widget support •  In-site bookmarking •  Full CRUD methods •  Documentation: Chinese http://demo.xadmin.io
  • 13. DJANGO ADMIN PLUGIN django-grappelli (by sehmaschine) •  Clean and consistent look & feel •  Related lookups with Autocompletes •  Inline sortables with Drag & Drop •  Compass-based CSS • Integrated TinyMCE theme • Customizable dashboard • Improved collapsibles • Unified jQuery-Plugins • Compatible with django—filebrowser
  • 14. DJANGO ADMIN PLUGIN django-admin2 (by pydanny) •  Rewrite of the Django Admin backend •  Drop-in themes •  Built-in RESTful API •  (django-rest-framework) django-admin-bootstrapped •  Bootstrap theme
  • 15. REFERENCE   Django official doc: https://docs.djangoproject.com/en/dev/ref/contrib/admin/   Django Book: http://django-book.readthedocs.org/en/latest/chapter06.html   Flask-admin doc: https://flask-admin.readthedocs.org/en/latest/   Flask-admin example: http://examples.flask-admin.org/   django-xadmin: https://github.com/sshwsfc/django-xadmin   django-grappelli: http://grappelliproject.com/   Django Packages - Admin Interface: https://www.djangopackages.com/grids/g/admin-interface/