Logo F2FInterview

Django Interview Questions

Q   |   QA
‹‹ previous12345

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Developed by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.

Django focuses on automating as much as possible and adhering to the DRY principle.

Django is named after Django Reinhardt, a gypsy jazz guitarist from the 1930s to early 1950s. To this day, he’s considered one of the best guitarists of all time.

Listen to his music. It will be liked.

Django is pronounced JANG-oh. Rhymes with FANG-oh. The “D” is silent.

Object-relational mapper

Define your data models entirely in Python. You get a rich, dynamic database-access API for free — but you can still write SQL if needed.

Automatic admin interface

Save yourself the tedious work of creating interfaces for people to add and update content. Django does that automatically, and it's production-ready.

Elegant URL design

Design pretty, cruft-free URLs with no framework-specific limitations. Be as flexible as you like.

Template system

Use Django's powerful, extensible and designer-friendly template language to separate design, content and Python code.

Cache system

Hook into memcached or other cache frameworks for super performance — caching is as granular as you need.

Internationalization

Django has full support for multi-language applications, letting you specify translation strings and providing hooks for language-specific functionality.

Configuration and Setup

  1. download django latest version from https://www.djangoproject.com/download/
  2. extract the file and paste it in to desire path (Eg. /opt/..). If can't paste directly use terminal mode using following command (sudo cp -fr Current_location/Django-1.3 /opt/)
  3. cd /opt/Django-1.3/ in terminal
  4. create a symbolic link for django-admin.py
    • sudo ln -s /opt/Django-1.3/django/bin/django-admin.py /usr/local/bin
  5. create a symbolic link fo django
    • sudo ln -s /opt/Django-1.3/django /usr/lib/python2.7/dist-packages/django

Start Project

  • django-admin.py startproject <proj name>
  • django-admin.py startapp <app name>

To Run Django Development Server

  • /directory/project_name$ python manage.py runserver (Eg. /Desktop/dj$ python manage.py runserver)
  • /directory/project_name$ python manage.py runserver your ip address (Eg. /Desktop/dj$ python manage.py runserver 192.168.2.6:8000)

For more Pls visit Django projects website.

The simplest way to look at Django is to break it down into its component parts. First off, there’s a models.py file which defines your data model by extrapolating your single lines of code into full database tables and adding a pre-built (totally optional) administration section to manage content.

The next element is the urls.py file which uses regular expressions to capture URL patterns for processing.

The actual processing happens in your views which, if you haven’t seen the pattern yet, live in views.py. This is really the meat of Django, since views are where you grab the data you’re presenting to the visitor.

Here’s what happens when a visitor lands on your Django page:

  1. First, Django consults the various URL patterns you’ve created and uses the information to retrieve a view.
  2. The view then processes the request, querying your database if necessary.
  3. The view passes the requested information on to your template.
  4. The template then renders the data in a layout you’ve created and displays the page.

‹‹ previous12345

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: