SlideShare uma empresa Scribd logo
1 de 15
The Django Admin Interface
Activate Django Admin Site Add 'django.contrib.admin' to your INSTALLED_APPS setting. Add - django.contrib.auth, django.contrib.contenttypes and django.contrib.messages.  Add django.contrib.messages.context_processors.messagesto TEMPLATE_CONTEXT_PROCESSORS and django.contrib.messages.middleware.MessageMiddlewaretoMIDDLEWARE_CLASSES.  Determine which of your application’s models should be editable in the admin interface. For each of those models, optionally create a ModelAdmin class that encapsulates the customized admin functionality and options for that particular model. Hook the AdminSite instance into your URLconf.
Exact Look
ModelAdmin The ModelAdmin class is the representation of a model in the admin interface.  These are stored in a file named admin.py in your application.  Eg : from django.contrib import admin from myproject.myapp.models import Author class AuthorAdmin(admin.ModelAdmin): 	//    Attributes admin.site.register(Author, AuthorAdmin)
Behavior  ModelAdmin.list_display fields are displayed on the change list page of the admin ModelAdmin.search_fields Set search_fields to enable a search box on the admin change list page ModelAdmin.ordering Set ordering to specify how lists of objects should be ordered in the Django admin views ModelAdmin.list_display_links Set list_display_links to control which fields in list_display should be linked to the "change" page for an object ModelAdmin.fields  if you want to only show a subset of the available fields in the form ModelAdmin.exclude  list of field names to exclude from the form
Behavior ModelAdmin.fieldsets : Set fieldsets to control the layout of admin "add" and "change" page fieldsets is a list of two-tuples, in which each two-tuple represents a <fieldset> on the admin form page. (A <fieldset> is a "section" of the form.) The two-tuples are in the format (name, field_options), where name is a string representing the title of the fieldset and field_options is a dictionary of information about the fieldset, including a list of fields to be displayed in it. ,[object Object],The paginator class to be used for pagination
Behavior Eg class FlatPageAdmin(admin.ModelAdmin): fieldsets = (         (None, {             'fields': ('url', 'title', 'content', 'sites')         }),         ('Advanced options', {             'classes': ('collapse',),             'fields': ('enable_comments', 'registration_required', 'template_name')         }),     ) To display multiple fields on the same line: { 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), }
admin actions need to make the same change to many objects Eg Suppose you want to make all the cache’s status as True def make_published(modeladmin, request, queryset): queryset.update(status=True) make_published.short_description = "Mark selected stories as published“ The current ModelAdmin An HttpRequest representing the current request, A QuerySet containing the set of objects selected by the user.
admin actions def make_available(modeladmin, request, queryset): queryset.update(status=True) make_available.short_description = "Mark selected cache’s as available“ # Just  add the actions in the admin model class ArticleAdmin(admin.ModelAdmin): list_display = ['title', 'status']          ordering = ['title']          actions = [make_available] Disable The Actions: admin.site.disable_action('delete_selected‘)
options A list of actions to make available on the change list page.  ModelAdmin.actions_on_top ModelAdmin.actions_on_bottom Controls where on the page the actions bar appears. By default, the admin changelist displays actions at the top of the page (actions_on_top = True; actions_on_bottom = False). ModelAdmin.actions_selection_counter Controls whether a selection counter is display next to the action dropdown. By default, the admin changelist will display it (actions_selection_counter = True).
Hooking AdminSite into URLconf # urls.py from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('',     (r'^admin/', include(admin.site.urls)),)
Hooking AdminSite into URLconf # urls.py from django.conf.urls.defaults import * from myproject.admin import admin_site urlpatterns = patterns('',     (r'^myadmin/', include(admin_site.urls)), )
Multiple admin sites in the same URLconf # urls.py from django.conf.urls.defaults import * from myproject.admin import basic_site, advanced_site urlpatterns = patterns('',     (r'^basic-admin/', include(basic_site.urls)),     (r'^advanced-admin/', include(advanced_site.urls)), )
Assignments Study the following  components ModelAdmin.filter_horizontal ModelAdmin.filter_vertical ModelAdmin.form ModelAdmin.formfield_overrides list_filter list_select_related prepopulated_fields ModelAdmin.radio_fields ModelAdmin.save_as ModelAdmin.save_on_top class InlineModelAdmin class TabularInline class StackedInline ModelAdmin.raw_id_fields
Thanks

Mais conteúdo relacionado

Mais procurados

Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's WorthAlex Gaynor
 
Editing the Visual Editor (WordPress)
Editing the Visual Editor (WordPress)Editing the Visual Editor (WordPress)
Editing the Visual Editor (WordPress)Jake Goldman
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 formsEyal Vardi
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)sroo galal
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentIvan Chepurnyi
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8flywindy
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex DevsAaronius
 
Django: Advanced Models
Django: Advanced ModelsDjango: Advanced Models
Django: Advanced ModelsYing-An Lai
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Eyal Vardi
 
WordPress Capabilities Magic
WordPress Capabilities MagicWordPress Capabilities Magic
WordPress Capabilities Magicmannieschumpert
 
Technical training sample
Technical training sampleTechnical training sample
Technical training sampleopenerpwiki
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2Eyal Vardi
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginnersSpin Lai
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in RailsSeungkyun Nam
 
Make your App Frontend Compatible
Make your App Frontend CompatibleMake your App Frontend Compatible
Make your App Frontend CompatibleOdoo
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS InternalEyal Vardi
 

Mais procurados (20)

Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Django design-patterns
Django design-patternsDjango design-patterns
Django design-patterns
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's Worth
 
Editing the Visual Editor (WordPress)
Editing the Visual Editor (WordPress)Editing the Visual Editor (WordPress)
Editing the Visual Editor (WordPress)
 
Angular 2.0 forms
Angular 2.0 formsAngular 2.0 forms
Angular 2.0 forms
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Two scoops of django 1.6 - Ch7, Ch8
Two scoops of django 1.6  - Ch7, Ch8Two scoops of django 1.6  - Ch7, Ch8
Two scoops of django 1.6 - Ch7, Ch8
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex Devs
 
Django: Advanced Models
Django: Advanced ModelsDjango: Advanced Models
Django: Advanced Models
 
Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)Angular 2 Architecture (Bucharest 26/10/2016)
Angular 2 Architecture (Bucharest 26/10/2016)
 
WordPress Capabilities Magic
WordPress Capabilities MagicWordPress Capabilities Magic
WordPress Capabilities Magic
 
Technical training sample
Technical training sampleTechnical training sample
Technical training sample
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 
Performance Optimization In Angular 2
Performance Optimization In Angular 2Performance Optimization In Angular 2
Performance Optimization In Angular 2
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginners
 
20150515ken
20150515ken20150515ken
20150515ken
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
Make your App Frontend Compatible
Make your App Frontend CompatibleMake your App Frontend Compatible
Make your App Frontend Compatible
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS Internal
 

Destaque

Magic Methods (Python meetup)
Magic Methods (Python meetup)Magic Methods (Python meetup)
Magic Methods (Python meetup)Ines Jelovac
 
Django Admin (Python meeutp)
Django Admin (Python meeutp)Django Admin (Python meeutp)
Django Admin (Python meeutp)Ines Jelovac
 
Are you and your computer guy praying 3
Are you and your computer guy praying 3Are you and your computer guy praying 3
Are you and your computer guy praying 3Phil Hutchins
 
Facebook Platform - Hack Thursday CW 40
Facebook Platform - Hack Thursday CW 40Facebook Platform - Hack Thursday CW 40
Facebook Platform - Hack Thursday CW 40William Dias
 
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016Eric Hyman
 
Amir33202057 2013 03-17-19-06-07
Amir33202057 2013 03-17-19-06-07Amir33202057 2013 03-17-19-06-07
Amir33202057 2013 03-17-19-06-07Dushyant Kumar
 
Setmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthroughSetmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthroughSetMore Appointments
 
HubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamrooHubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamrooMegan Ng
 
Enterprise Risk Management
Enterprise Risk ManagementEnterprise Risk Management
Enterprise Risk ManagementClayton Scott
 
Inception Product Feature Webinar: Workflow, Versioning & Restore
Inception Product Feature Webinar: Workflow, Versioning & RestoreInception Product Feature Webinar: Workflow, Versioning & Restore
Inception Product Feature Webinar: Workflow, Versioning & RestoreMarco Makfab
 
Product families
Product familiesProduct families
Product familiesManageware
 
Design is...
Design is...Design is...
Design is...Anh Cao
 
Trance'former présentation eng
Trance'former présentation engTrance'former présentation eng
Trance'former présentation enggms project
 
SFPUC and DataSplice Mobile for Maximo
SFPUC and DataSplice Mobile for MaximoSFPUC and DataSplice Mobile for Maximo
SFPUC and DataSplice Mobile for MaximoDataSplice
 
OnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and ModeratorsOnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and ModeratorsRobert Strobl
 
Government encourages education loan
Government encourages education loanGovernment encourages education loan
Government encourages education loanMonica Sharma
 

Destaque (20)

Magic Methods (Python meetup)
Magic Methods (Python meetup)Magic Methods (Python meetup)
Magic Methods (Python meetup)
 
Django Admin (Python meeutp)
Django Admin (Python meeutp)Django Admin (Python meeutp)
Django Admin (Python meeutp)
 
Are you and your computer guy praying 3
Are you and your computer guy praying 3Are you and your computer guy praying 3
Are you and your computer guy praying 3
 
Facebook Platform - Hack Thursday CW 40
Facebook Platform - Hack Thursday CW 40Facebook Platform - Hack Thursday CW 40
Facebook Platform - Hack Thursday CW 40
 
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016
EarthLink Top 5 Questions Asked of EarthLInk Network Engineers 2016
 
Amir33202057 2013 03-17-19-06-07
Amir33202057 2013 03-17-19-06-07Amir33202057 2013 03-17-19-06-07
Amir33202057 2013 03-17-19-06-07
 
Via3 Project In Control
Via3 Project In ControlVia3 Project In Control
Via3 Project In Control
 
Setmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthroughSetmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthrough
 
HubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamrooHubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamroo
 
Serveau software f
Serveau software fServeau software f
Serveau software f
 
Appraisly November 2013
Appraisly November 2013Appraisly November 2013
Appraisly November 2013
 
Enterprise Risk Management
Enterprise Risk ManagementEnterprise Risk Management
Enterprise Risk Management
 
Inception Product Feature Webinar: Workflow, Versioning & Restore
Inception Product Feature Webinar: Workflow, Versioning & RestoreInception Product Feature Webinar: Workflow, Versioning & Restore
Inception Product Feature Webinar: Workflow, Versioning & Restore
 
Product families
Product familiesProduct families
Product families
 
Design is...
Design is...Design is...
Design is...
 
Trance'former présentation eng
Trance'former présentation engTrance'former présentation eng
Trance'former présentation eng
 
SFPUC and DataSplice Mobile for Maximo
SFPUC and DataSplice Mobile for MaximoSFPUC and DataSplice Mobile for Maximo
SFPUC and DataSplice Mobile for Maximo
 
OnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and ModeratorsOnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and Moderators
 
Government encourages education loan
Government encourages education loanGovernment encourages education loan
Government encourages education loan
 
TechZarInfo web design and development
TechZarInfo web design and developmentTechZarInfo web design and development
TechZarInfo web design and development
 

Semelhante a DJango admin interface

Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudParakram Chavda
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant TrainingAidIQ
 
Symfony Admin Generator - generator.yml
Symfony Admin Generator - generator.ymlSymfony Admin Generator - generator.yml
Symfony Admin Generator - generator.ymlRavi Mone
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendalltutorialsruby
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendalltutorialsruby
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3Javier Eguiluz
 
WebClient Customization.pdf
WebClient Customization.pdfWebClient Customization.pdf
WebClient Customization.pdfsatyasekhar123
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Pluginsnavjeet
 
Web-based application development part 31MINIMIZE .docx
Web-based application development part 31MINIMIZE .docxWeb-based application development part 31MINIMIZE .docx
Web-based application development part 31MINIMIZE .docxcelenarouzie
 
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdf
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdfAlready given code from 4 files- 1-app-ctrl-js code- -- include expres.pdf
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdfas1mobiles
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails Mohit Jain
 

Semelhante a DJango admin interface (20)

Classic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crudClassic asp , VB.net insert update delete crud
Classic asp , VB.net insert update delete crud
 
Comilla University
Comilla University Comilla University
Comilla University
 
Struts 2
Struts 2Struts 2
Struts 2
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant Training
 
Symfony Admin Generator - generator.yml
Symfony Admin Generator - generator.ymlSymfony Admin Generator - generator.yml
Symfony Admin Generator - generator.yml
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
 
RubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendallRubyOnRails-Cheatsheet-BlaineKendall
RubyOnRails-Cheatsheet-BlaineKendall
 
Jsf
JsfJsf
Jsf
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
WebClient Customization.pdf
WebClient Customization.pdfWebClient Customization.pdf
WebClient Customization.pdf
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Plugins
 
Web-based application development part 31MINIMIZE .docx
Web-based application development part 31MINIMIZE .docxWeb-based application development part 31MINIMIZE .docx
Web-based application development part 31MINIMIZE .docx
 
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdf
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdfAlready given code from 4 files- 1-app-ctrl-js code- -- include expres.pdf
Already given code from 4 files- 1-app-ctrl-js code- -- include expres.pdf
 
Django
DjangoDjango
Django
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 
Alfredo-PUMEX
Alfredo-PUMEXAlfredo-PUMEX
Alfredo-PUMEX
 

Último

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Último (20)

JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

DJango admin interface

  • 1. The Django Admin Interface
  • 2. Activate Django Admin Site Add 'django.contrib.admin' to your INSTALLED_APPS setting. Add - django.contrib.auth, django.contrib.contenttypes and django.contrib.messages. Add django.contrib.messages.context_processors.messagesto TEMPLATE_CONTEXT_PROCESSORS and django.contrib.messages.middleware.MessageMiddlewaretoMIDDLEWARE_CLASSES. Determine which of your application’s models should be editable in the admin interface. For each of those models, optionally create a ModelAdmin class that encapsulates the customized admin functionality and options for that particular model. Hook the AdminSite instance into your URLconf.
  • 4. ModelAdmin The ModelAdmin class is the representation of a model in the admin interface. These are stored in a file named admin.py in your application. Eg : from django.contrib import admin from myproject.myapp.models import Author class AuthorAdmin(admin.ModelAdmin): // Attributes admin.site.register(Author, AuthorAdmin)
  • 5. Behavior ModelAdmin.list_display fields are displayed on the change list page of the admin ModelAdmin.search_fields Set search_fields to enable a search box on the admin change list page ModelAdmin.ordering Set ordering to specify how lists of objects should be ordered in the Django admin views ModelAdmin.list_display_links Set list_display_links to control which fields in list_display should be linked to the "change" page for an object ModelAdmin.fields if you want to only show a subset of the available fields in the form ModelAdmin.exclude list of field names to exclude from the form
  • 6.
  • 7. Behavior Eg class FlatPageAdmin(admin.ModelAdmin): fieldsets = ( (None, { 'fields': ('url', 'title', 'content', 'sites') }), ('Advanced options', { 'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name') }), ) To display multiple fields on the same line: { 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), }
  • 8. admin actions need to make the same change to many objects Eg Suppose you want to make all the cache’s status as True def make_published(modeladmin, request, queryset): queryset.update(status=True) make_published.short_description = "Mark selected stories as published“ The current ModelAdmin An HttpRequest representing the current request, A QuerySet containing the set of objects selected by the user.
  • 9. admin actions def make_available(modeladmin, request, queryset): queryset.update(status=True) make_available.short_description = "Mark selected cache’s as available“ # Just add the actions in the admin model class ArticleAdmin(admin.ModelAdmin): list_display = ['title', 'status'] ordering = ['title'] actions = [make_available] Disable The Actions: admin.site.disable_action('delete_selected‘)
  • 10. options A list of actions to make available on the change list page. ModelAdmin.actions_on_top ModelAdmin.actions_on_bottom Controls where on the page the actions bar appears. By default, the admin changelist displays actions at the top of the page (actions_on_top = True; actions_on_bottom = False). ModelAdmin.actions_selection_counter Controls whether a selection counter is display next to the action dropdown. By default, the admin changelist will display it (actions_selection_counter = True).
  • 11. Hooking AdminSite into URLconf # urls.py from django.conf.urls.defaults import * from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)),)
  • 12. Hooking AdminSite into URLconf # urls.py from django.conf.urls.defaults import * from myproject.admin import admin_site urlpatterns = patterns('', (r'^myadmin/', include(admin_site.urls)), )
  • 13. Multiple admin sites in the same URLconf # urls.py from django.conf.urls.defaults import * from myproject.admin import basic_site, advanced_site urlpatterns = patterns('', (r'^basic-admin/', include(basic_site.urls)), (r'^advanced-admin/', include(advanced_site.urls)), )
  • 14. Assignments Study the following components ModelAdmin.filter_horizontal ModelAdmin.filter_vertical ModelAdmin.form ModelAdmin.formfield_overrides list_filter list_select_related prepopulated_fields ModelAdmin.radio_fields ModelAdmin.save_as ModelAdmin.save_on_top class InlineModelAdmin class TabularInline class StackedInline ModelAdmin.raw_id_fields