Thursday, May 16, 2013

About Django MVC


Those three pieces together – data access logic, business logic, and presentation logic – comprise a concept that’s sometimes called the Model-View-Controller (MVC) pattern of software architecture.

Django fallows this MVC pattern and it can be called as MVC framework. Here’s roughly how the M, V, and C break down in Django:

Controller : A controller is the heart of the system, it steers everything. For a web framework, this means handling requests and responses, setting up database connections and loading add-ons. For this, Django reads a settings file so that it knows what to load and set up. And Django reads a URL config file that tells it what to do with the incoming requests from browsers.

Model :  The model layer in Django means the database plus the Python code that directly uses it. It models reality. You capture whatever your website needs in database tables. Django helps you write Python classes (called models) that tie 1:1 to the database tables.

View : The view layer is the user interface. Django splits this up in the actual HTML pages and the Python code (called views) that renders them. And it also has an automatic web admin interface for editing the models



You also see MVT(Model, View , Template) explanation. There is a confusion b/w MVC view and python view and then you considered Django as MVT Framework J

M stands for “Model,” the data access layer.

T stands for “Template,” the presentation layer

V stands for “View,” the business logic layer.

Tuesday, May 14, 2013

How to colorize the Git output?

Git can color its output to your terminal, which can help you visually parse the output quickly and easily. A number of options can help you set the coloring to your preference.
color.ui

Git automatically colors most of its output if you ask it to. You can get very specific about what you want colored and how; but to turn on all the default terminal coloring, set color.ui to true:

$ git config --global color.ui true
When that value is set, Git colors its output if the output goes to a terminal

You can use the following command if you want output to use color when written to the terminal

$ git config --global color.ui auto
color.ui: The color.ui is a meta configuration that includes all the various color.* configurations available with git commands. This is explained in-depth in git help config


In-depth explanation from the git config documentation:


Monday, May 13, 2013

Work with Django IDE using PyDev (Eclipse plugin)

Most of the time, you might be working with command prompt and text editors to develop django based website.

If you are an eclipse lover, you can use PyDev plug-in, which is an excellent tool that helps django developers in working with IDE

Prerequisites:
  1. Java
    1. If you are working on Ubuntu, run the following commands
      1. Install JRE by running the command, "sudo apt-get install openjdk-6-jre-headless"
      2. Install JDK by running "sudo apt-get install openjdk-6-jdk"
  2. Download eclipse from eclipse.org
    1.  you can download eclipse classic
    2. extract the tar file
    3. launch "eclipse" from the extracted folder
  3. Install PyDev Plugin
    1. Go to "Help > Install new software" 
    2. Click on "Add"
      1. From the 'Add Repository' window, enter some name for 'Name' field, say 'PyDev' and 'http://pydev.org/updates' in the 'Location' field.  
      2. Click on 'OK'
    3. Select "PyDev", and click on 'Next'
    4. Select 'Next' for the 'Install Details' window
    5. Accept the licence agreement by selecting the 'I accept ..." radio button and click on 'Finish'
    6. Wait for the software get download and install
    7. When prompted to select the certificates (window with text 'Do you want to trust these certificates?' with options 'Aptana Pydev; Pydev'), select the certificate and click on 'OK'
    8. After installation, eclipse prompts you to reboot the application
  4. From the Eclipse, go to "Window > Preferences > PyDev > Interpreter-Python", click on 'Auto Config', and then select 'OK'

  5. Click on 'Apply' and then 'OK'
  6. Now, you can create Django project by going to "File > New > Other > PyDev > PyDev Django Project"

How to Install Django and Mysql in Ubuntu Linux

Ubuntu is a very friendly environment for ubuntu developers.
Installation of Django is very simple.

Requirements:
  1. Python (no need to install separately, it will be as part of Ubuntu OS)
  2. Mysql server (if you would like to use mysql database)
  3. Python mysql db connector
  4. Latest Django tar file from djangoproject.com

Procedure:
  1. from the terminal (command prompt), install mysql-server by running the command "sudo apt-get install mysql-server"
  2. After sql server is installed, install python-mysqldb connector by running the following command "sudo apt-get install python-mysqldb"
  3. Download the latest django tar file from www.djangoproject.com, and run the following commands
    1. extract the tar file (use "tar xzvf Django-xxx.tar.gz" from the terminal window)
    2. From the terminal window, go to the extracted folder path by running the command "cd Django-xxx"
    3. run the command "sudo python setup.py install"

That's simple it is... You are ready go with  django development.

Welcome

Hi,
Welcome to My Blog.

Thank You for visiting my blog

-Srikanth Gurram