SlideShare a Scribd company logo
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

More Related Content

What's hot

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 Worth
Alex 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 forms
Eyal 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, Ch8
flywindy
 
JavaScript for Flex Devs
JavaScript for Flex DevsJavaScript for Flex Devs
JavaScript for Flex Devs
Aaronius
 
Django: Advanced Models
Django: Advanced ModelsDjango: Advanced Models
Django: Advanced Models
Ying-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 Magic
mannieschumpert
 
Technical training sample
Technical training sampleTechnical training sample
Technical training sample
openerpwiki
 
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 2
Eyal Vardi
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginners
Spin Lai
 
20150515ken
20150515ken20150515ken
20150515ken
LearningTech
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
Seungkyun Nam
 
Make your App Frontend Compatible
Make your App Frontend CompatibleMake your App Frontend Compatible
Make your App Frontend Compatible
Odoo
 
AngularJS Internal
AngularJS InternalAngularJS Internal
AngularJS Internal
Eyal Vardi
 

What's hot (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
 

Viewers also liked

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 40
William 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
 
Via3 Project In Control
Via3 Project In ControlVia3 Project In Control
Via3 Project In Control
Via3 new marketing & media
 
Setmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthroughSetmore zendesk integration - quick walkthrough
Setmore zendesk integration - quick walkthrough
SetMore Appointments
 
HubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamrooHubSpot Activation on BlueCamroo
HubSpot Activation on BlueCamroo
Megan Ng
 
Serveau software f
Serveau software fServeau software f
Serveau software f
Mohammed Boumahdi
 
Enterprise Risk Management
Enterprise Risk ManagementEnterprise Risk Management
Enterprise Risk Management
Clayton 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 & Restore
Marco Makfab
 
Product families
Product familiesProduct families
Product families
Manageware
 
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 Maximo
DataSplice
 
OnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and ModeratorsOnSync Manual Account Holders and Moderators
OnSync Manual Account Holders and Moderators
Robert Strobl
 
Government encourages education loan
Government encourages education loanGovernment encourages education loan
Government encourages education loan
Monica Sharma
 
TechZarInfo web design and development
TechZarInfo web design and developmentTechZarInfo web design and development
TechZarInfo web design and development
TechZarInfo Software and Consulting Services
 

Viewers also liked (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
 

Similar to 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 crud
Parakram Chavda
 
Comilla University
Comilla University Comilla University
Struts 2
Struts 2Struts 2
Struts 2
Lalit Garg
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 
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.yml
Ravi 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 3
Javier Eguiluz
 
WebClient Customization.pdf
WebClient Customization.pdfWebClient Customization.pdf
WebClient Customization.pdf
satyasekhar123
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Plugins
navjeet
 
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
celenarouzie
 
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
as1mobiles
 
Django
DjangoDjango
Django
Ivan Widodo
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
Mohit Jain
 

Similar to 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
 

Recently uploaded

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
amberjdewit93
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
MERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDFMERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDF
scholarhattraining
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 

Recently uploaded (20)

PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
MERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDFMERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDF
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 

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