Django admin


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Django admin

  1. 1. Django admin Petter ArvidssonSoftware architect at Fyndiq AB
  2. 2. What is the Django admin application?● Its a ● framework for rapidly developing administrative backends ● well integrated part of Django● Its not a ● lightweight DBMS – Doesnt compare to e.g. phpMyAdmin ● CMS – There exists applications that extends Django and admin to be a CMS
  3. 3. Admin in relation to DjangoModel Declarative Change list Inferred ModelAdminModelForm Change/add view
  4. 4. Models Model Change list ● Everyone knows Model about Models, right? Admin Model Change ● Declarative definitions Form /add view of data bundles ● Provides validation● Tip ● Model fields contains several options that are directly linked to their behaviour in ModelForms ● Provides data ● (and therefore indirectly in admin): Blank, choices, editable, help_text, verbose_name consistency
  5. 5. ModelForms Model Change ● Fields are declared from the list Fields present in the Model Model Admin ● Provides validation Model Form Change /add ● Including user friendly error view messages ● Renders as HTML● Tip ● Including error messages ● Forms keeps tracks of which fields that have changed. A model form that is given an instance will automatically populate the changed_data ● Easily customizable property with any fields that were changed ● Can create or update a bound model instance
  6. 6. Admin in relation to DjangoModel Declarative Change list Inferred ModelAdminModelForm Change/add view
  7. 7. ModelAdmin Model Change ● Defines the change list and list the change/add view Model Admin ● Customizable Model Change ● Change list Form /add view – Columns – Sorting – Search● Tip – Filtering ● ModelAdmins can inherit in the same – … way as Models can inherit. A powerful pattern is to complement abstract ● Change/add view models with ModelAdmin classes – Fields – Inline – Create your own ModelForm – …
  8. 8. Admin actions Model Change ● Bulk actions on steroids list ● Filter, search, select and then Model Admin execute Model Change ● Define your own actions Form /add view ● Actions are methods on the ModelAdmin ● Global actions (generic for all● Tip models) ● Use admin actions to filter other ● Local actions (specialized for admin views one model) ● E.g. select an author and create an action to show all books written by her/him
  9. 9. Result Model Change list ● Well defined, user Model friendly administrative Admin interfaces Model Change Form /add view ● Extremely short development times● Tip ● The fact that Django is highly modular does not by itself imply that its a good idea to start only using a limited amount of modules. E.g. if you build your application only using Models it might be really hard to add Forms and Admin later on
  10. 10. Where to go next?● Django documentation● James Bennet, Django in Depth at PyCon US 2012 (available from● Django/contrib/admin/● Join us?