ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Method-based views
in Django applications
      Gary Reynolds
     Touch Technology

           @goodtune
     bitbucket.org/goodtune
      github.com/goodtune
Refresher

? Last time we looked at building up a library
  which will help save us some boilerplate
? It incorporated better form ?elds, simple
  decorated mixins to enforce
  authentication, and a few other niceties
This time
 ? What if we need to deploy the same
    application multiple times?
 ? In our URLconf we could point to the
    applications urls.py as many times as we
    need...
from django.conf.urls.defaults import patterns, url

urlpatterns = patterns('',
    url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&),
    url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&),
)
Issues
? If your application requires con?guration at
  run-time, you probably use a custom
  settings.MYAPP_VAR or similar?
? That will usually apply globally, not per
  mount point.
? If the application was an instance with it¡¯s
  own state, the issue goes away.
Basic anatomy
class MyApp(object):

   def __init__(self, name='myapp', app_name='myapp'):
       self.name = name
       self.app_name = app_name

   def get_urls(self):
       urlpatterns = patterns('',
           url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&),
       )

   @property
   def urls(self):
       return self.get_urls(), self.app_name, self.name

   def index(self, request):
       return HttpResponse('')
Let¡¯s see it in practice
Horses for courses
? This book store is missing a view for the
  details of a book.
? It really is an admin application, allowing
  authenticated creation and updating of
  Book instances by authenticated users.
? Lets use inheritance to split the
  functionality.
Subclass our application
Real world example
? Tournament Control is an application for
  managing sporting competitions
 ? Scheduling ?xtures
 ? Allocating matches to grounds &
    timeslots
 ? Recording results and automatic ladder
    updates
Tournament Control
? Shameless plug
 ? http://www.sydney.touch.asn.au/
 ? http://www.touchsuperleague.org.uk/
 ? http://www.touchworldcup2011.co.uk/
? We¡¯re interested in Touch Superleague
  because they run multiple application
  instances - they have venues in Edinburgh,
  Cardiff, and Jersey.
Method based views in django applications
Lets look at
             the front-end

www.touchsuperleague.org.uk/edinburgh/draws-ladders
Questions?
? Sample project can be obtained from
  bitbucket.org

 ? bitbucket.org/goodtune/sydjango-
    example-two

? This presentation can be downloaded from
  ºÝºÝߣShare

 ? slideshare.net/goodtune/method-based-
    views-in-django-applications-14050952

More Related Content

What's hot (13)

Active Admin
Active AdminActive Admin
Active Admin
Greg Bell
?
Troubleshooting APEX Performance Issues
Troubleshooting APEX Performance IssuesTroubleshooting APEX Performance Issues
Troubleshooting APEX Performance Issues
Roel Hartman
?
Bare acl
Bare aclBare acl
Bare acl
Sudheer Satyanarayana
?
Apache Stratos: the PaaS from Apache
Apache Stratos: the PaaS from ApacheApache Stratos: the PaaS from Apache
Apache Stratos: the PaaS from Apache
WSO2
?
REST API for your WP7 App
REST API for your WP7 AppREST API for your WP7 App
REST API for your WP7 App
Agnius Paradnikas
?
The Most Valuable Corporate Gifts That Your Employees Will Love
The Most Valuable Corporate Gifts That Your Employees Will LoveThe Most Valuable Corporate Gifts That Your Employees Will Love
The Most Valuable Corporate Gifts That Your Employees Will Love
Augrav
?
Get rss to blogger
Get rss to bloggerGet rss to blogger
Get rss to blogger
bharathlisting
?
EmberJS BucharestJS
EmberJS BucharestJSEmberJS BucharestJS
EmberJS BucharestJS
Remus Rusanu
?
Lighting talk android espesso recorder
Lighting talk   android espesso recorderLighting talk   android espesso recorder
Lighting talk android espesso recorder
Douglas Leandro Kleinkauf
?
Apas
ApasApas
Apas
GreekTuts ¦¥¦Ë¦Ë¦Ç¦Í¦É¦Ê? ¦¢¦Ï¦Ç¦È?¦Ì¦Á¦Ó¦Á
?
Action Bar Sherlock tutorial
Action Bar Sherlock tutorialAction Bar Sherlock tutorial
Action Bar Sherlock tutorial
Ahsanul Karim
?
Rails engine
Rails engineRails engine
Rails engine
Jyaasa Technologies
?
Introduction to ember js
Introduction to ember jsIntroduction to ember js
Introduction to ember js
Adnan Arshad
?

Similar to Method based views in django applications (20)

Angular Intermediate
Angular IntermediateAngular Intermediate
Angular Intermediate
LinkMe Srl
?
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
?
Cakeph pppt
Cakeph ppptCakeph pppt
Cakeph pppt
Wizard Rider
?
Ei cakephp
Ei cakephpEi cakephp
Ei cakephp
eiei lay
?
Pluggable patterns
Pluggable patternsPluggable patterns
Pluggable patterns
Corey Oordt
?
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
Joseph Khan
?
Modern Automated Site Provisioning for SharePoint Online
Modern Automated Site Provisioning for SharePoint OnlineModern Automated Site Provisioning for SharePoint Online
Modern Automated Site Provisioning for SharePoint Online
DocFluix, LLC
?
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practices
paulbowler
?
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
Ö®Óî Úw
?
Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
DjangoCon2008
?
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
Dimitri de Putte
?
Django Overview
Django OverviewDjango Overview
Django Overview
Brian Tol
?
PyCaret_PedramJahangiryTUTORIALPYTHON.pdf
PyCaret_PedramJahangiryTUTORIALPYTHON.pdfPyCaret_PedramJahangiryTUTORIALPYTHON.pdf
PyCaret_PedramJahangiryTUTORIALPYTHON.pdf
wpanjikresno
?
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
kevinvw
?
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
Deepak Garg
?
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
?
Tango with django
Tango with djangoTango with django
Tango with django
Rajan Kumar Upadhyay
?
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
murtazahaveliwala
?
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Udit Gangwani
?
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Mike Schinkel
?
Angular Intermediate
Angular IntermediateAngular Intermediate
Angular Intermediate
LinkMe Srl
?
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
?
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
Joseph Khan
?
Modern Automated Site Provisioning for SharePoint Online
Modern Automated Site Provisioning for SharePoint OnlineModern Automated Site Provisioning for SharePoint Online
Modern Automated Site Provisioning for SharePoint Online
DocFluix, LLC
?
Grails patterns and practices
Grails patterns and practicesGrails patterns and practices
Grails patterns and practices
paulbowler
?
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
Ö®Óî Úw
?
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
Dimitri de Putte
?
Django Overview
Django OverviewDjango Overview
Django Overview
Brian Tol
?
PyCaret_PedramJahangiryTUTORIALPYTHON.pdf
PyCaret_PedramJahangiryTUTORIALPYTHON.pdfPyCaret_PedramJahangiryTUTORIALPYTHON.pdf
PyCaret_PedramJahangiryTUTORIALPYTHON.pdf
wpanjikresno
?
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
kevinvw
?
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
Deepak Garg
?
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
?
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Udit Gangwani
?
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Mike Schinkel
?

Recently uploaded (20)

The Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptxThe Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptx
zsbaranyai
?
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
Network_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptxNetwork_Packet_Brokers_Presentation.pptx
Network_Packet_Brokers_Presentation.pptx
Khushi Communications
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
Columbia Weather Systems - Product Overview
Columbia Weather Systems - Product OverviewColumbia Weather Systems - Product Overview
Columbia Weather Systems - Product Overview
Columbia Weather Systems
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-WorldAll-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
Safe Software
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Testing Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptxTesting Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptx
Julia Undeutsch
?
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
?
Recruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OGRecruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OG
Matt Charney
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc¨ªa Lavilla
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
The Future of Materials: Transitioning from Silicon to Alternative Metals
The Future of Materials: Transitioning from Silicon to Alternative MetalsThe Future of Materials: Transitioning from Silicon to Alternative Metals
The Future of Materials: Transitioning from Silicon to Alternative Metals
anupriti
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥ÈDragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
CRI Japan, Inc.
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
202408_JAWSPANKRATION_Introduction_of_Minaden.pdf
NTTDOCOMO-ServiceInnovation
?
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
?
The Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptxThe Road to SAP S4HANA Cloud with SAP Activate.pptx
The Road to SAP S4HANA Cloud with SAP Activate.pptx
zsbaranyai
?
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly MeetupBeyond the life of a CISO -  Head of Trust at GDG Kathmandu Monthly Meetup
Beyond the life of a CISO - Head of Trust at GDG Kathmandu Monthly Meetup
GDG Kathmandu
?
AI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting HiringAI in Talent Acquisition: Boosting Hiring
AI in Talent Acquisition: Boosting Hiring
Beyond Chiefs
?
STARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to PonderSTARLINK-JIO-AIRTEL Security issues to Ponder
STARLINK-JIO-AIRTEL Security issues to Ponder
anupriti
?
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-WorldAll-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
All-Data, Any-AI Integration: FME & Amazon Bedrock in the Real-World
Safe Software
?
Least Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role PermissionsLeast Privilege AWS IAM Role Permissions
Least Privilege AWS IAM Role Permissions
Chris Wahl
?
Testing Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptxTesting Tools for Accessibility Enhancement Part II.pptx
Testing Tools for Accessibility Enhancement Part II.pptx
Julia Undeutsch
?
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and FeastSmarter RAG Pipelines: Scaling Search with Milvus and Feast
Smarter RAG Pipelines: Scaling Search with Milvus and Feast
Zilliz
?
Recruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OGRecruiting Tech: A Look at Why AI is Actually OG
Recruiting Tech: A Look at Why AI is Actually OG
Matt Charney
?
Research Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research processResearch Data Management (RDM): the management of dat in the research process
Research Data Management (RDM): the management of dat in the research process
HeilaPienaar
?
Microsoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdfMicrosoft Digital Defense Report 2024 .pdf
Microsoft Digital Defense Report 2024 .pdf
Abhishek Agarwal
?
The Future of Materials: Transitioning from Silicon to Alternative Metals
The Future of Materials: Transitioning from Silicon to Alternative MetalsThe Future of Materials: Transitioning from Silicon to Alternative Metals
The Future of Materials: Transitioning from Silicon to Alternative Metals
anupriti
?
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptxPackaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
Packaging your App for AppExchange ¨C Managed Vs Unmanaged.pptx
mohayyudin7826
?
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥ÈDragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN  NB-IoT  LTE cat.M1ÉÌÆ·¥ê¥¹¥È
Dragino¥×¥í¥À¥¯¥È¥«¥¿¥í¥° LoRaWAN NB-IoT LTE cat.M1ÉÌÆ·¥ê¥¹¥È
CRI Japan, Inc.
?
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly MeetupLeadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
Leadership Spectrum by Sonam Sherpa at GDG Kathmandu March Monthly Meetup
GDG Kathmandu
?
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMARSTRING FUNCTIONS IN JAVA BY N SARATH KUMAR
STRING FUNCTIONS IN JAVA BY N SARATH KUMAR
Sarathkumar Narsupalli
?

Method based views in django applications

  • 1. Method-based views in Django applications Gary Reynolds Touch Technology @goodtune bitbucket.org/goodtune github.com/goodtune
  • 2. Refresher ? Last time we looked at building up a library which will help save us some boilerplate ? It incorporated better form ?elds, simple decorated mixins to enforce authentication, and a few other niceties
  • 3. This time ? What if we need to deploy the same application multiple times? ? In our URLconf we could point to the applications urls.py as many times as we need... from django.conf.urls.defaults import patterns, url urlpatterns = patterns('', url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&), url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&), )
  • 4. Issues ? If your application requires con?guration at run-time, you probably use a custom settings.MYAPP_VAR or similar? ? That will usually apply globally, not per mount point. ? If the application was an instance with it¡¯s own state, the issue goes away.
  • 5. Basic anatomy class MyApp(object): def __init__(self, name='myapp', app_name='myapp'): self.name = name self.app_name = app_name def get_urls(self): urlpatterns = patterns('', url(/slideshow/method-based-views-in-django-applications-14050952/14050952/r&), ) @property def urls(self): return self.get_urls(), self.app_name, self.name def index(self, request): return HttpResponse('')
  • 6. Let¡¯s see it in practice
  • 7. Horses for courses ? This book store is missing a view for the details of a book. ? It really is an admin application, allowing authenticated creation and updating of Book instances by authenticated users. ? Lets use inheritance to split the functionality.
  • 9. Real world example ? Tournament Control is an application for managing sporting competitions ? Scheduling ?xtures ? Allocating matches to grounds & timeslots ? Recording results and automatic ladder updates
  • 10. Tournament Control ? Shameless plug ? http://www.sydney.touch.asn.au/ ? http://www.touchsuperleague.org.uk/ ? http://www.touchworldcup2011.co.uk/ ? We¡¯re interested in Touch Superleague because they run multiple application instances - they have venues in Edinburgh, Cardiff, and Jersey.
  • 12. Lets look at the front-end www.touchsuperleague.org.uk/edinburgh/draws-ladders
  • 14. ? Sample project can be obtained from bitbucket.org ? bitbucket.org/goodtune/sydjango- example-two ? This presentation can be downloaded from ºÝºÝߣShare ? slideshare.net/goodtune/method-based- views-in-django-applications-14050952