SlideShare a Scribd company logo
'   '
django-admin.py startproject mysite


/settings.py

DATABASE_ENGINE = 'mysql'
DATABASE_NAME = 'mysite_db'
DATABASE_USER = 'sergio'
DATABASE_PASSWORD = 'qwerty'
DATABASE_HOST = ''
DATABASE_PORT = ''
rails mysite


/config/database.yml

development:
      adapter: mysql
      encoding: utf8
      database: mysite_db
      username: sergio
      password: qwerty
mysite/
                          mysite/
    __init__.py
                              app/
    manage.py
                                  controllers/
    settings.py
                                  helpers/
    urls.py
                                  models/
                                  views/
                              config/
manage.py startapp blog
                              db/
                              doc/
mysite/
                              lib/
    blog/
                              log/
        __init__.py
                              public/
        models.py
                              script/
        views.py
                              test/
                              tmp/
                              vendor/
/db/schema.rb

ActiveRecord::Schema.define(:version => 0) do
    create_table :posts do |t|
        t.string   :title
        t.text     :description
        t.string   :url
    end
end

/app/models/post.rb

class Post < ActiveRecord::Base
    belongs_to :user
    has_many   :comments
end
/blog/models.py


class Post(models.Model):
    title = models.CharField( max_length=120 )
    description = models.TextField()
    url = models.URLField( verify_exists=True )

   user = models.ForeignKey( User )


class Comment(models.Model):
    ...
   post = models.ForeignKey( Post, related_name=„comments‟)
class AddDetailsToProducts < ActiveRecord::Migration

      def self.up
          add_column :posts, :category, :string
      end

      def self.down
          remove_column :posts, :category
      end
end


rake db:migrate
Class Table Inheritance


class Person(models.Model):
    name = models.CharField( max_length=120 )


class Worker( Person ):
    job = models.CharField( max_length=120 )


class Client( Person ):
   email = models.EmailField()
/urls.py

(r'^blog/(?P<post_id>d+)', blog.views.show_post),



/blog/views.py

def show_post(request, post_id):

    post = get_object_or_404(Post, id=post_id)
    return render_to_response(„blog/post.html',
                              {„post': post})
GENERIC VIEWS

/urls.py

#Url: /blog/123

(r'^blog/(?P<object_id>d+)',
    'django.views.generic.list_detail.object_detail',
    { 'queryset': Post.objects.all() } )



#Template -> blog/post_detail.html
/app/controllers/blog_controller.rb

# URL: /blog/post/123
def post
    @post = Post.find( params[:id] )
end

# Template: /app/views/blog/post.html.erb


/config/routes.rb

#URL: /blog/123
map.connect „blog/:id‟, :controller => „blog‟, :action => „post‟
/app/views/layouts/blog.html.erb

<html><body>
    <h1>
        <%= link_to „Blog‟, :controller => „blog‟ %>
    </h1>
    <%= yield %>
</body></html>


/app/views/blog/create.html.erb

<% form_for :post, @post, :url => {:action => "create”} do |f| %>
    <%= f.text_field :title%>
    <%= f.text_field :description %>
    <%= submit_tag 'Create' %>
<% end %>
/blog/main.html

<html>
    <head>
         <title>
             {% block title %}Blog{% endblock %}
         </title>
    </head>
    <body>
        <h1>
            <a href=“/blog”>Blog</a>
        </h1>
        {% block content %}{% endblock %}
    </body>
</html>
/blog/forms.py

Class PostForm(ModelForm):
    class Meta:
        model = Post


/blog/create.html

{% block title %}Create a new post{% endblock %}

{% block content %}
    <form action="/blog/create" method="POST">
        {{ form.as_ul }}
        <input type="submit" value="Submit" />
    </form>
{% endblock %}
manage.py startapp blog


INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'mysite.blog'
)

urlpatterns = patterns('',

    (r'^blog/', include('mysite.blog.urls')),
)
Rails::Initializer.run do |config|
  config.gem "haml"
  config.gem "chronic", :version => '0.2.3'
  config.gem "hpricot", :source => http://code.whytheluckystiff.net
end



ruby script/plugin install
    http://svn.techno-weenie.net/projects/plugins/restful_authentication/
script/generate controller Blog
      exists app/controllers/
      exists app/helpers/
      create app/views/blog
   > exists test/functional/
   > create test/unit/helpers/
      create app/controllers/blog_controller.rb
   > create test/functional/blog_controller_test.rb
      create app/helpers/blog_helper.rb
   > create test/unit/helpers/blog_helper_test.rb




Rspec, cucumber, shoulda, mocha, webrat...
Doctests
def my_func(a_list, index):
    """
    >>> a = ['larry', 'curly', 'moe']
    >>> my_func(a, 0)
    'larry'
    >>> my_func(a, 1)
    'curly'
    """
    return a_list[index]



Unit Tests
class MyFuncTestCase(unittest.TestCase):
    def testBasic(self):
        a = ['larry', 'curly', 'moe']
        self.assertEquals(my_func(a, 0), 'larry')
        self.assertEquals(my_func(a, 1), 'curly')
Guides.rubyonrails.orgWorking With Rails
• Web applications for information management
• Reusable components
• Common functionalities built-in
  - Authentication
  - Authorization (permissions)
  - Image or file upload
  ...
•   Less common web applications
•   AJAX intensive
•   Dedicated hosting and support
•   Heavy testing
•   Specialized tools
Content

• http://superjared.com/entry/rails-versus-django/

• http://wiki.alcidesfonseca.com/rails-vs-django/

• http://www.scribd.com/doc/121814/RailsDjango-Comparison

• http://docs.google.com/View?docid=dcn8282p_1hg4sr9

• http://www.magpiebrain.com/blog/2005/08/14/a-
comparison-of-django-with-rails/
Photos

•   Title - http://www.flickr.com/photos/dunechaser/2936384537/
•   Introduction - http://www.flickr.com/photos/dunechaser/2630433944/
•   Disclaimer - http://www.flickr.com/photos/jazamarripae/1936251344/
•   Frameworks Background - http://www.flickr.com/photos/albaum/430677776/
•   Initial configuration - http://www.flickr.com/photos/somethingstartedcrazyy/1352607255/
•   Structure - http://www.flickr.com/photos/9160678@N06/578966742/
•   Database & Models - http://www.flickr.com/photos/shindotv/3835365695/
•   Controllers/Views - http://www.flickr.com/photos/p1r/633300342/
•   Views/Templates - http://www.flickr.com/photos/gigi62/3092670031/
•   Administration - http://www.flickr.com/photos/fotopakismo/1183485780/
•   Extensibility - http://www.flickr.com/photos/grdloizaga/817443503/
•   Testing - http://www.flickr.com/photos/telstar/422117665/
•   Communities - http://www.flickr.com/photos/pugetive/506788681/
•   Conclusions - http://www.flickr.com/photos/argenberg/188043461/
•   Sources - http://www.flickr.com/photos/quarenta/2876309035/
Django Vs Rails

More Related Content

What's hot

DJango admin interface
DJango admin interfaceDJango admin interface
DJango admin interface
Mahesh Shitole
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
Mark
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
DrupalSPB
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
wanglei999
 
ui-router and $state
ui-router and $stateui-router and $state
ui-router and $state
garbles
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
Mizanur Rahaman Mizan
 
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
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal Development
Jeff Eaton
 
2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The Hood2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The Hood
James Walker
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developers
Dream Production AG
 
Ruby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxRuby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxWen-Tien Chang
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
allilevine
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
Dzmitry Ivashutsin
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
Ui router
Ui routerUi router
Ui router
Marilyn Waldman
 
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - MojitoDundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojitosmartads
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksHjörtur Hilmarsson
 
Drupal 7 — Circle theme
Drupal 7 — Circle themeDrupal 7 — Circle theme
Drupal 7 — Circle theme
Kirill Borzov
 
Rails Routing and URL design
Rails Routing and URL designRails Routing and URL design
Rails Routing and URL designhiq5
 

What's hot (20)

DJango admin interface
DJango admin interfaceDJango admin interface
DJango admin interface
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
 
实战Ecos
实战Ecos实战Ecos
实战Ecos
 
ui-router and $state
ui-router and $stateui-router and $state
ui-router and $state
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginners
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal Development
 
2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The Hood2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The Hood
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developers
 
Ruby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxRuby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 Ajax
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
WordCamp Montreal 2015: Combining Custom Post Types, Fields, and Meta Boxes t...
 
Get AngularJS Started!
Get AngularJS Started!Get AngularJS Started!
Get AngularJS Started!
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel Makhrinsky
 
Ui router
Ui routerUi router
Ui router
 
Dundee University HackU 2013 - Mojito
Dundee University HackU 2013 - MojitoDundee University HackU 2013 - Mojito
Dundee University HackU 2013 - Mojito
 
Javascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & TricksJavascript MVC & Backbone Tips & Tricks
Javascript MVC & Backbone Tips & Tricks
 
Drupal 7 — Circle theme
Drupal 7 — Circle themeDrupal 7 — Circle theme
Drupal 7 — Circle theme
 
Rails Routing and URL design
Rails Routing and URL designRails Routing and URL design
Rails Routing and URL design
 

Similar to Django Vs Rails

Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Django
DjangoDjango
Django
Ivan Widodo
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
WordPress plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3
giwoolee
 
Django
DjangoDjango
Django
Kangjin Jun
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
Simon Willison
 
Intro to Pylons / Pyramid
Intro to Pylons / PyramidIntro to Pylons / Pyramid
Intro to Pylons / PyramidEric Paxton
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Luka Zakrajšek
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
Jason Davies
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
Wade Austin
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
Wake Liu
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
Jacob Kaplan-Moss
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
Dirk Haun
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 

Similar to Django Vs Rails (20)

Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Django
DjangoDjango
Django
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
WordPress plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3
 
Django
DjangoDjango
Django
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
 
Intro to Pylons / Pyramid
Intro to Pylons / PyramidIntro to Pylons / Pyramid
Intro to Pylons / Pyramid
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # Twig
 
What's new in Django 1.2?
What's new in Django 1.2?What's new in Django 1.2?
What's new in Django 1.2?
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 

More from Sérgio Santos

Launching tech products
Launching tech productsLaunching tech products
Launching tech products
Sérgio Santos
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails apps
Sérgio Santos
 
Ultra fast web development with sinatra
Ultra fast web development with sinatraUltra fast web development with sinatra
Ultra fast web development with sinatra
Sérgio Santos
 
Agoge - produtividade & multitasking
Agoge - produtividade & multitaskingAgoge - produtividade & multitasking
Agoge - produtividade & multitasking
Sérgio Santos
 
Ontologias
OntologiasOntologias
Ontologias
Sérgio Santos
 
Workshop Django
Workshop DjangoWorkshop Django
Workshop Django
Sérgio Santos
 
Gestão De Projectos
Gestão De ProjectosGestão De Projectos
Gestão De Projectos
Sérgio Santos
 
Gestor - Casos De Uso
Gestor - Casos De UsoGestor - Casos De Uso
Gestor - Casos De Uso
Sérgio Santos
 

More from Sérgio Santos (9)

Launching tech products
Launching tech productsLaunching tech products
Launching tech products
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails apps
 
Rails + mongo db
Rails + mongo dbRails + mongo db
Rails + mongo db
 
Ultra fast web development with sinatra
Ultra fast web development with sinatraUltra fast web development with sinatra
Ultra fast web development with sinatra
 
Agoge - produtividade & multitasking
Agoge - produtividade & multitaskingAgoge - produtividade & multitasking
Agoge - produtividade & multitasking
 
Ontologias
OntologiasOntologias
Ontologias
 
Workshop Django
Workshop DjangoWorkshop Django
Workshop Django
 
Gestão De Projectos
Gestão De ProjectosGestão De Projectos
Gestão De Projectos
 
Gestor - Casos De Uso
Gestor - Casos De UsoGestor - Casos De Uso
Gestor - Casos De Uso
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

Django Vs Rails

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. ' '
  • 9.
  • 10. django-admin.py startproject mysite /settings.py DATABASE_ENGINE = 'mysql' DATABASE_NAME = 'mysite_db' DATABASE_USER = 'sergio' DATABASE_PASSWORD = 'qwerty' DATABASE_HOST = '' DATABASE_PORT = ''
  • 11. rails mysite /config/database.yml development: adapter: mysql encoding: utf8 database: mysite_db username: sergio password: qwerty
  • 12.
  • 13. mysite/ mysite/ __init__.py app/ manage.py controllers/ settings.py helpers/ urls.py models/ views/ config/ manage.py startapp blog db/ doc/ mysite/ lib/ blog/ log/ __init__.py public/ models.py script/ views.py test/ tmp/ vendor/
  • 14.
  • 15. /db/schema.rb ActiveRecord::Schema.define(:version => 0) do create_table :posts do |t| t.string :title t.text :description t.string :url end end /app/models/post.rb class Post < ActiveRecord::Base belongs_to :user has_many :comments end
  • 16. /blog/models.py class Post(models.Model): title = models.CharField( max_length=120 ) description = models.TextField() url = models.URLField( verify_exists=True ) user = models.ForeignKey( User ) class Comment(models.Model): ... post = models.ForeignKey( Post, related_name=„comments‟)
  • 17. class AddDetailsToProducts < ActiveRecord::Migration def self.up add_column :posts, :category, :string end def self.down remove_column :posts, :category end end rake db:migrate
  • 18. Class Table Inheritance class Person(models.Model): name = models.CharField( max_length=120 ) class Worker( Person ): job = models.CharField( max_length=120 ) class Client( Person ): email = models.EmailField()
  • 19.
  • 20. /urls.py (r'^blog/(?P<post_id>d+)', blog.views.show_post), /blog/views.py def show_post(request, post_id): post = get_object_or_404(Post, id=post_id) return render_to_response(„blog/post.html', {„post': post})
  • 21. GENERIC VIEWS /urls.py #Url: /blog/123 (r'^blog/(?P<object_id>d+)', 'django.views.generic.list_detail.object_detail', { 'queryset': Post.objects.all() } ) #Template -> blog/post_detail.html
  • 22. /app/controllers/blog_controller.rb # URL: /blog/post/123 def post @post = Post.find( params[:id] ) end # Template: /app/views/blog/post.html.erb /config/routes.rb #URL: /blog/123 map.connect „blog/:id‟, :controller => „blog‟, :action => „post‟
  • 23.
  • 24. /app/views/layouts/blog.html.erb <html><body> <h1> <%= link_to „Blog‟, :controller => „blog‟ %> </h1> <%= yield %> </body></html> /app/views/blog/create.html.erb <% form_for :post, @post, :url => {:action => "create”} do |f| %> <%= f.text_field :title%> <%= f.text_field :description %> <%= submit_tag 'Create' %> <% end %>
  • 25. /blog/main.html <html> <head> <title> {% block title %}Blog{% endblock %} </title> </head> <body> <h1> <a href=“/blog”>Blog</a> </h1> {% block content %}{% endblock %} </body> </html>
  • 26. /blog/forms.py Class PostForm(ModelForm): class Meta: model = Post /blog/create.html {% block title %}Create a new post{% endblock %} {% block content %} <form action="/blog/create" method="POST"> {{ form.as_ul }} <input type="submit" value="Submit" /> </form> {% endblock %}
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. manage.py startapp blog INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'mysite.blog' ) urlpatterns = patterns('', (r'^blog/', include('mysite.blog.urls')), )
  • 32. Rails::Initializer.run do |config| config.gem "haml" config.gem "chronic", :version => '0.2.3' config.gem "hpricot", :source => http://code.whytheluckystiff.net end ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
  • 33.
  • 34. script/generate controller Blog exists app/controllers/ exists app/helpers/ create app/views/blog > exists test/functional/ > create test/unit/helpers/ create app/controllers/blog_controller.rb > create test/functional/blog_controller_test.rb create app/helpers/blog_helper.rb > create test/unit/helpers/blog_helper_test.rb Rspec, cucumber, shoulda, mocha, webrat...
  • 35. Doctests def my_func(a_list, index): """ >>> a = ['larry', 'curly', 'moe'] >>> my_func(a, 0) 'larry' >>> my_func(a, 1) 'curly' """ return a_list[index] Unit Tests class MyFuncTestCase(unittest.TestCase): def testBasic(self): a = ['larry', 'curly', 'moe'] self.assertEquals(my_func(a, 0), 'larry') self.assertEquals(my_func(a, 1), 'curly')
  • 36.
  • 38.
  • 39.
  • 40. • Web applications for information management • Reusable components • Common functionalities built-in - Authentication - Authorization (permissions) - Image or file upload ...
  • 41. Less common web applications • AJAX intensive • Dedicated hosting and support • Heavy testing • Specialized tools
  • 42.
  • 43. Content • http://superjared.com/entry/rails-versus-django/ • http://wiki.alcidesfonseca.com/rails-vs-django/ • http://www.scribd.com/doc/121814/RailsDjango-Comparison • http://docs.google.com/View?docid=dcn8282p_1hg4sr9 • http://www.magpiebrain.com/blog/2005/08/14/a- comparison-of-django-with-rails/
  • 44. Photos • Title - http://www.flickr.com/photos/dunechaser/2936384537/ • Introduction - http://www.flickr.com/photos/dunechaser/2630433944/ • Disclaimer - http://www.flickr.com/photos/jazamarripae/1936251344/ • Frameworks Background - http://www.flickr.com/photos/albaum/430677776/ • Initial configuration - http://www.flickr.com/photos/somethingstartedcrazyy/1352607255/ • Structure - http://www.flickr.com/photos/9160678@N06/578966742/ • Database & Models - http://www.flickr.com/photos/shindotv/3835365695/ • Controllers/Views - http://www.flickr.com/photos/p1r/633300342/ • Views/Templates - http://www.flickr.com/photos/gigi62/3092670031/ • Administration - http://www.flickr.com/photos/fotopakismo/1183485780/ • Extensibility - http://www.flickr.com/photos/grdloizaga/817443503/ • Testing - http://www.flickr.com/photos/telstar/422117665/ • Communities - http://www.flickr.com/photos/pugetive/506788681/ • Conclusions - http://www.flickr.com/photos/argenberg/188043461/ • Sources - http://www.flickr.com/photos/quarenta/2876309035/