SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
'   '
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

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

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

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

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 

Kürzlich hochgeladen (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 

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/