SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

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