SlideShare a Scribd company logo
1 of 45
Download to read offline
'   '
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 interfaceMahesh 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.jsMark
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapDrupalSPB
 
ui-router and $state
ui-router and $stateui-router and $state
ui-router and $stategarbles
 
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 3Mizanur Rahaman Mizan
 
Django class based views for beginners
Django class based views for beginnersDjango class based views for beginners
Django class based views for beginnersSpin Lai
 
Drupal Development
Drupal DevelopmentDrupal Development
Drupal DevelopmentJeff Eaton
 
2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The Hood2007 Fsoss Drupal Under The Hood
2007 Fsoss Drupal Under The HoodJames Walker
 
Drupal Javascript for developers
Drupal Javascript for developersDrupal Javascript for developers
Drupal Javascript for developersDream 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
 
Render API - Pavel Makhrinsky
Render API - Pavel MakhrinskyRender API - Pavel Makhrinsky
Render API - Pavel MakhrinskyDrupalCampDN
 
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 themeKirill 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
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
WordPress plugin #3
WordPress plugin #3WordPress plugin #3
WordPress plugin #3giwoolee
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
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 BeginnersJason Davies
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
PHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigPHPConf-TW 2012 # Twig
PHPConf-TW 2012 # TwigWake Liu
 
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 FrameworkDirk Haun
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 

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 productsSérgio Santos
 
Simple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSimple MongoDB design for Rails apps
Simple MongoDB design for Rails appsSérgio Santos
 
Ultra fast web development with sinatra
Ultra fast web development with sinatraUltra fast web development with sinatra
Ultra fast web development with sinatraSérgio Santos
 
Agoge - produtividade & multitasking
Agoge - produtividade & multitaskingAgoge - produtividade & multitasking
Agoge - produtividade & multitaskingSé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

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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/