Discuss Django ”; Previous Next Django is a web development framework that assists in building and maintaining quality web applications. Django helps eliminate repetitive tasks making the development process an easy and time saving experience. This tutorial gives a complete understanding of Django. Print Page Previous Next Advertisements ”;
Category: django
Django – Comments
Django – Comments ”; Previous Next Before starting, note that the Django Comments framework is deprecated, since the 1.5 version. Now you can use external feature for doing so, but if you still want to use it, it”s still included in version 1.6 and 1.7. Starting version 1.8 it”s absent but you can still get the code on a different GitHub account. The comments framework makes it easy to attach comments to any model in your app. To start using the Django comments framework − Edit the project settings.py file and add ”django.contrib.sites”, and ”django.contrib.comments”, to INSTALLED_APPS option − INSTALLED_APPS += (”django.contrib.sites”, ”django.contrib.comments”,) Get the site id − >>> from django.contrib.sites.models import Site >>> Site().save() >>> Site.objects.all()[0].id u”56194498e13823167dd43c64” Set the id you get in the settings.py file − SITE_ID = u”56194498e13823167dd43c64” Sync db, to create all the comments table or collection − python manage.py syncdb Add the comment app’s URLs to your project’s urls.py − from django.conf.urls import include url(r”^comments/”, include(”django.contrib.comments.urls”)), Now that we have the framework installed, let”s change our hello templates to tracks comments on our Dreamreal model. We will list, save comments for a specific Dreamreal entry whose name will be passed as parameter to the /myapp/hello URL. Dreamreal Model class Dreamreal(models.Model): website = models.CharField(max_length = 50) mail = models.CharField(max_length = 50) name = models.CharField(max_length = 50) phonenumber = models.IntegerField() class Meta: db_table = “dreamreal” hello view def hello(request, Name): today = datetime.datetime.now().date() daysOfWeek = [”Mon”, ”Tue”, ”Wed”, ”Thu”, ”Fri”, ”Sat”, ”Sun”] dreamreal = Dreamreal.objects.get(name = Name) return render(request, ”hello.html”, locals()) hello.html template {% extends “main_template.html” %} {% load comments %} {% block title %}My Hello Page{% endblock %} {% block content %} <p> Our Dreamreal Entry: <p><strong>Name :</strong> {{dreamreal.name}}</p> <p><strong>Website :</strong> {{dreamreal.website}}</p> <p><strong>Phone :</strong> {{dreamreal.phonenumber}}</p> <p><strong>Number of comments :<strong> {% get_comment_count for dreamreal as comment_count %} {{ comment_count }}</p> <p>List of comments :</p> {% render_comment_list for dreamreal %} </p> {% render_comment_form for dreamreal %} {% endblock %} Finally the mapping URL to our hello view − url(r”^hello/(?P<Name>w+)/”, ”hello”, name = ”hello”), Now, In our template (hello.html), load the comments framework with − {% load comments %} We get the number of comments for the Dreamreal object pass by the view − {% get_comment_count for dreamreal as comment_count %} We get the list of comments for the objects − {% render_comment_list for dreamreal %} We display the default comments form − {% render_comment_form for dreamreal %} When accessing /myapp/hello/steve you will get the comments info for the Dreamreal entry whose name is Steve. Accessing that URL will get you − On posting a comment, you will get redirected to the following page − If you go to /myapp/hello/steve again, you will get to see the following page − As you can see, the number of comments is 1 now and you have the comment under the list of comments line. Print Page Previous Next Advertisements ”;
Django – Apache Setup
Django – Apache Setup ”; Previous Next So far, in our examples, we have used the Django dev web server. But this server is just for testing and is not fit for production environment. Once in production, you need a real server like Apache, Nginx, etc. Let”s discuss Apache in this chapter. Serving Django applications via Apache is done by using mod_wsgi. So the first thing is to make sure you have Apache and mod_wsgi installed. Remember, when we created our project and we looked at the project structure, it looked like − myproject/ manage.py myproject/ __init__.py settings.py urls.py wsgi.py The wsgi.py file is the one taking care of the link between Django and Apache. Let”s say we want to share our project (myproject) with Apache. We just need to set Apache to access our folder. Assume we put our myproject folder in the default “/var/www/html”. At this stage, accessing the project will be done via 127.0.0.1/myproject. This will result in Apache just listing the folder as shown in the following snapshot. As seen, Apache is not handling Django stuff. For this to be taken care of, we need to configure Apache in httpd.conf. So open the httpd.conf and add the following line − WSGIScriptAlias / /var/www/html/myproject/myproject/wsgi.py WSGIPythonPath /var/www/html/myproject/ <Directory /var/www/html/myproject/> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> If you can access the login page as 127.0.0.1/myapp/connection, you will get to see the following page − Print Page Previous Next Advertisements ”;
Django – Page Not Found (404) ”; Previous Next What is 404 Page Not Found Error? The HTTP protocol defines various status codes to indicate different types of HTTP responses. “404” is the HTTP status code that corresponds to the situation when the server cannot find the requested webpage. It is called as “404 error”, also known as the “404 Not Found error” or “HTTP 404 Not Found”. Django”s Default Template for 404 Error In Django, a given URL route is mapped to a certain view. The 404 error may appear when a URL doesn’t have a corresponding view. Let us enter a URL route that has not been defined in the URLCONF of the Django project − The Django project, created with the startproject template, has the DEBUG parameter set to TRUE. The above page appears when a view isn”t found and DEBUG is set to TRUE. This is Django’s default template for 404 error code. Render a Custom Error Page To render a custom error page, set the DEBUG parameter to FALSE in the “setings.py” module. Also, you need to specify the list of ALLOWED_HOSTS such as localhost or a certain domain such as https://example.com. Set this parameter to “*” for any hostname. DEBUG = False ALLOWED_HOSTS = [“*”] After these changes, the same URL doesn’t show any DEBUG message as in the earlier figure. You can further design a customised template, name it as “404.html”, and place it in the “BASE_DIR/template” folder. 404.html <html> <body> <h2 style=”text-align: center; color: blue; font-weight:900;”>The Page is Not found</h2> </body> </html> Now, this page is displayed whenever the view is not found. Another approach to customize the 404 error response is to define a handler404() view in “views.py” file under the project folder. Note − The view.py module is situated by default in the app folder. You need to create the same in the project folder explicitly. views.py from django.shortcuts import render def handler404(request, exception): return render(request, ”404handler.html”) Then, direct Django to render this template whenever a view isn’t found by assigning the handler404 variable with handler404() function, in the URLCONF of the project. urls.py from django.contrib import admin from django.urls import path from . import views handler404 = views.handler404 urlpatterns = [ path(”admin/”, admin.site.urls), ] 404handler.html Save the following HTML script as 404handler.html in the templates folder − <html> <body> <h2 style=”text-align: center; color: blue; font-weight:900;”>The Page is Not found</h2> <br> <br> <a href=”../home”><b>Back to Home</b></a> </body> </html> Visit any undefined URL route to render this customized 404 error page. Print Page Previous Next Advertisements ”;
Django – URL Mapping
Django – URL Mapping ”; Previous Next Now that we have a working view as explained in the previous chapters. We want to access that view via a URL. Django has his own way for URL mapping and it”s done by editing your project url.py file (myproject/url.py). The url.py file looks like − from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns(””, #Examples #url(r”^$”, ”myproject.view.home”, name = ”home”), #url(r”^blog/”, include(”blog.urls”)), url(r”^admin”, include(admin.site.urls)), ) When a user makes a request for a page on your web app, Django controller takes over to look for the corresponding view via the url.py file, and then return the HTML response or a 404 not found error, if not found. In url.py, the most important thing is the “urlpatterns” tuple. It’s where you define the mapping between URLs and views. A mapping is a tuple in URL patterns like − from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns(””, #Examples #url(r”^$”, ”myproject.view.home”, name = ”home”), #url(r”^blog/”, include(”blog.urls”)), url(r”^admin”, include(admin.site.urls)), url(r”^hello/”, ”myapp.views.hello”, name = ”hello”), ) The marked line maps the URL “/home” to the hello view created in myapp/view.py file. As you can see above a mapping is composed of three elements − The pattern − A regexp matching the URL you want to be resolved and map. Everything that can work with the python ”re” module is eligible for the pattern (useful when you want to pass parameters via url). The python path to the view − Same as when you are importing a module. The name − In order to perform URL reversing, you’ll need to use named URL patterns as done in the examples above. Once done, just start the server to access your view via :http://127.0.0.1/hello Organizing Your URLs So far, we have created the URLs in “myprojects/url.py” file, however as stated earlier about Django and creating an app, the best point was to be able to reuse applications in different projects. You can easily see what the problem is, if you are saving all your URLs in the “projecturl.py” file. So best practice is to create an “url.py” per application and to include it in our main projects url.py file (we included admin URLs for admin interface before). How is it Done? We need to create an url.py file in myapp using the following code − from django.conf.urls import patterns, include, url urlpatterns = patterns(””, url(r”^hello/”, ”myapp.views.hello”, name = ”hello”),) Then myproject/url.py will change to the following − from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns(””, #Examples #url(r”^$”, ”myproject.view.home”, name = ”home”), #url(r”^blog/”, include(”blog.urls”)), url(r”^admin”, include(admin.site.urls)), url(r”^myapp/”, include(”myapp.urls”)), ) We have included all URLs from myapp application. The home.html that was accessed through “/hello” is now “/myapp/hello” which is a better and more understandable structure for the web app. Now let”s imagine we have another view in myapp “morning” and we want to map it in myapp/url.py, we will then change our myapp/url.py to − from django.conf.urls import patterns, include, url urlpatterns = patterns(””, url(r”^hello/”, ”myapp.views.hello”, name = ”hello”), url(r”^morning/”, ”myapp.views.morning”, name = ”morning”), ) This can be re-factored to − from django.conf.urls import patterns, include, url urlpatterns = patterns(”myapp.views”, url(r”^hello/”, ”hello”, name = ”hello”), url(r”^morning/”, ”morning”, name = ”morning”),) As you can see, we now use the first element of our urlpatterns tuple. This can be useful when you want to change your app name. Sending Parameters to Views We now know how to map URL, how to organize them, now let us see how to send parameters to views. A classic sample is the article example (you want to access an article via “/articles/article_id”). Passing parameters is done by capturing them with the regexp in the URL pattern. If we have a view like the following one in “myapp/view.py” from django.shortcuts import render from django.http import HttpResponse def hello(request): return render(request, “hello.html”, {}) def viewArticle(request, articleId): text = “Displaying article Number : %s”%articleId return HttpResponse(text) We want to map it in myapp/url.py so we can access it via “/myapp/article/articleId”, we need the following in “myapp/url.py” − from django.conf.urls import patterns, include, url urlpatterns = patterns(”myapp.views”, url(r”^hello/”, ”hello”, name = ”hello”), url(r”^morning/”, ”morning”, name = ”morning”), url(r”^article/(d+)/”, ”viewArticle”, name = ”article”),) When Django will see the url: “/myapp/article/42” it will pass the parameters ”42” to the viewArticle view, and in your browser you should get the following result − Note that the order of parameters is important here. Suppose we want the list of articles of a month of a year, let”s add a viewArticles view. Our view.py becomes − from django.shortcuts import render from django.http import HttpResponse def hello(request): return render(request, “hello.html”, {}) def viewArticle(request, articleId): text = “Displaying article Number : %s”%articleId return HttpResponse(text) def viewArticle(request, month, year): text = “Displaying articles of : %s/%s”%(year, month) return HttpResponse(text) The corresponding url.py file will look like − from django.conf.urls import patterns, include, url urlpatterns = patterns(”myapp.views”, url(r”^hello/”, ”hello”, name = ”hello”), url(r”^morning/”, ”morning”, name = ”morning”), url(r”^article/(d+)/”, ”viewArticle”, name = ”article”), url(r”^articles/(d{2})/(d{4})”, ”viewArticles”, name = ”articles”),) Now when you go to “/myapp/articles/12/2006/” you will get ”Displaying articles of: 2006/12” but if you reverse the parameters you won’t get the same result. To avoid that, it is possible to link a URL parameter to the view parameter. For that, our url.py will become − from django.conf.urls import patterns, include, url urlpatterns = patterns(”myapp.views”, url(r”^hello/”, ”hello”, name = ”hello”), url(r”^morning/”, ”morning”, name = ”morning”), url(r”^article/(d+)/”, ”viewArticle”, name = ”article”), url(r”^articles/(?Pd{2})/(?Pd{4})”, ”viewArticles”, name = ”articles”),) Print Page Previous Next Advertisements ”;
Django – Page Redirection
Django – Page Redirection ”; Previous Next Page redirection is needed for many reasons in web application. You might want to redirect a user to another page when a specific action occurs, or basically in case of error. For example, when a user logs in to your website, he is often redirected either to the main home page or to his personal dashboard. In Django, redirection is accomplished using the ”redirect” method. The ”redirect” method takes as argument: The URL you want to be redirected to as string A view”s name. The myapp/views looks like the following so far − def hello(request): today = datetime.datetime.now().date() daysOfWeek = [”Mon”, ”Tue”, ”Wed”, ”Thu”, ”Fri”, ”Sat”, ”Sun”] return render(request, “hello.html”, {“today” : today, “days_of_week” : daysOfWeek}) def viewArticle(request, articleId): “”” A view that display an article based on his ID””” text = “Displaying article Number : %s” %articleId return HttpResponse(text) def viewArticles(request, year, month): text = “Displaying articles of : %s/%s”%(year, month) return HttpResponse(text) Let”s change the hello view to redirect to djangoproject.com and our viewArticle to redirect to our internal ”/myapp/articles”. To do so the myapp/view.py will change to − from django.shortcuts import render, redirect from django.http import HttpResponse import datetime # Create your views here. def hello(request): today = datetime.datetime.now().date() daysOfWeek = [”Mon”, ”Tue”, ”Wed”, ”Thu”, ”Fri”, ”Sat”, ”Sun”] return redirect(“https://www.djangoproject.com”) def viewArticle(request, articleId): “”” A view that display an article based on his ID””” text = “Displaying article Number : %s” %articleId return redirect(viewArticles, year = “2045”, month = “02”) def viewArticles(request, year, month): text = “Displaying articles of : %s/%s”%(year, month) return HttpResponse(text) In the above example, first we imported redirect from django.shortcuts and for redirection to the Django official website we just pass the full URL to the ”redirect” method as string, and for the second example (the viewArticle view) the ”redirect” method takes the view name and his parameters as arguments. Accessing /myapp/hello, will give you the following screen − And accessing /myapp/article/42, will give you the following screen − It is also possible to specify whether the ”redirect” is temporary or permanent by adding permanent = True parameter. The user will see no difference, but these are details that search engines take into account when ranking of your website. Also remember that ”name” parameter we defined in our url.py while mapping the URLs − url(r”^articles/(?Pd{2})/(?Pd{4})/”, ”viewArticles”, name = ”articles”), That name (here article) can be used as argument for the ”redirect” method, then our viewArticle redirection can be changed from − def viewArticle(request, articleId): “”” A view that display an article based on his ID””” text = “Displaying article Number : %s” %articleId return redirect(viewArticles, year = “2045”, month = “02”) To − def viewArticle(request, articleId): “”” A view that display an article based on his ID””” text = “Displaying article Number : %s” %articleId return redirect(articles, year = “2045”, month = “02”) Note − There is also a function to generate URLs; it is used in the same way as redirect; the ”reverse” method (django.core.urlresolvers.reverse). This function does not return a HttpResponseRedirect object, but simply a string containing the URL to the view compiled with any passed argument. Print Page Previous Next Advertisements ”;
Django – Add CSS Files
Django – Add CSS Files ”; Previous Next CSS (Cascading Style Sheets) is an important component of the World Wide Web alongside HTML and JavaScript. It is a style sheet language used for specifying the presentation and styling of a document written in HTML. CSS Files are Static Assets In Django, CSS files are termed as static assets. They are placed in the static folder which is created inside the app’s “package” folder. The static assets are made available with the following template tag − {% load static %} Normally, the CSS file is included in the HTML code with the following statement, usually placed in the <head> section. <link rel=”stylesheet” type=”text/css” href=”styles.css” /> However, to include CSS as a static resource, its path is mentioned with {% static %} tag as follows − <link rel=”stylesheet” type=”text/css” href=”{% static ”style.css” %}”> Applying CSS to the Name of Cities Here we will show how you can apply CSS to the name of cities displayed as an unordered list in the web page. Let us define the following index() view that passes a list of cities as a context to a “cities.html” template from django.shortcuts import render def index(request): cities = [”Mumbai”, ”New Delhi”, ”Kolkata”, ”Bengaluru”, ”Chennai”, ”Hyderabad”] return render(request, “cities.html”, {“cities”:cities}) cities.html In the “cities.html” template, we first load the CSS file in the HEAD section. Each name is rendered in the <li> . . </li> tag with the help of a for loop template tag. <html> <head> {% load static %} <link rel=”stylesheet” type=”text/css” href=”{% static ”style.css” %}”> </head> <body> <h2>List of Cities</h2> <ul> {% for city in cities %} <li>{{ city }} </li> {% endfor %} </ul> </body> </html> style.css We shall apply background color to the webpage and set its font size and color. Save the following code as “style.css” and put it in the static folder. h2 { text-align: center; font-size:xx-large; color:red; } ul li { color: darkblue; font-size:20; } body { background-color: violet; } Register the index() View The index() view is registered in the urlpatterns of the Django app as follows − from django.urls import path from . import views urlpatterns = [ path(“”, views.index, name=”index”), ] The http://localhost:8000/myapp/ URL displays the list of cities according to the above styles − Print Page Previous Next Advertisements ”;
Django Admin â Set Fields to Display ”; Previous Next When a model is registered to Djangoâs Admin site, its list of objects is displayed when you click the name of the model. In the following figure, the list of objects in the Employees model is displayed − However, the above page shows the objects in the form Employee object(1), which doesnât reveal the attributes such as the name or contact, etc. To make the object description more user-friendly, we need to override the __str__() method in the employee model class. The employee class is rewritten as below to give the alternate string representation of its object. from django.db import models class Employee(models.Model): empno = models.CharField(max_length=20) empname = models.CharField(max_length=100) contact = models.CharField(max_length=15) salary = models.IntegerField() joined_date = models.DateField(null=True) class Meta: db_table = “employee” def __str__(self): return “Name: {}, Contact: {}”.format(self.empname, self.contact) Make these changes to the model definition, and refresh the admin siteâs homepage (Start the Django server if it isnât already running). Click the Employees model under MYAPP to display the employee object details − If you click any of the object details, a form that shows the object attributes appears, and you can update the object or delete the object from here. You can customize the “change list page” with the “list_display” attribute of an admin.ModelAdmin object that specifies what columns are shown in the change list. The ModelAdmin class is the representation of a model in the admin interface. Usually, these are stored in a file called admin.py in your application. Define the EmployeeAdmin class by inheriting from the ModelAdmin class. Set the list_display attribute as a tuple of the fields to be displayed. from django.contrib import admin # Register your models here. from .models import Employee class EmployeeAdmin(admin.ModelAdmin): list_display = (“empname”, “contact”, “joined_date”) Register the EmployeeAdmin class as follows − admin.site.register(Employee, EmployeeAdmin) You can also register the model using the @admin.register() decorator − from django.contrib import admin # Register your models here. from .models import Employee @admin.register(Employee) class EmployeeAdmin(admin.ModelAdmin): list_display = (“empname”, “contact”, “joined_date”) Save the above changes and refresh the Admin site to display the list of Employee objects − You can also provide a searching facility to the list page. Add search_fields attribute in the EmployeeAdmin class − @admin.register(Employee) class EmployeeAdmin(admin.ModelAdmin): list_display = (“empname”, “contact”, “joined_date”) search_fields = (“empname__startswith”, ) Now the list page shows a search field on the top. The search is based on employeeâs name. The __startswith modifier restricts the search to names that begin with the search parameter. Thus, the Django Admin interface is completely customizable. You can set the fields to be provided in the update form by providing the fields attribute in the admin class. Print Page Previous Next Advertisements ”;
Django – Update Model
Django â Update Model ”; Previous Next Djangoâs ORM API provides useful functionality for performing CRUD operations on the data stored in the tables of relational databases. The create(), update() and delete() methods perform their respective operations on an already existing table. However, you often need to make changes to the model structure itself, by adding, deleting or altering the attributes of the model. Djangoâs admin interface can be helpful in handling these activities. The Migration System in Django Django has a powerful migration system that deals with the process of updating a model. Django propagates the changes you make to your models (adding a field, deleting a model, etc.) into your database schema with the help Migrations mechanism. The migrations-related commands are executed with the manage.py script. The following commands are available − migrate − Responsible for applying and unapplying migrations. makemigrations − Responsible for creating new migrations based on the changes made to the models. sqlmigrate − Displays the SQL statements for a migration. showmigrations − Lists a projectâs migrations and their status. When you first set up a Django project, it automatically installs certain apps. They are listed in the INSTALLED_APPS section in the settings.py module. Most of these apps are used in the admin interface to create and manage the users, groups, authorization, etc., and the data related to these apps is stored in the respective tables. We need to run the following migrate command for the first time to create the table structure required for INSTALLED_APPS − python manage.py migrate Running the above command will create a package called migrations inside the app package folder. All the subsequent migration scripts are stored in it. Subsequently, when you create a new app (with startapp command), you also need to add it in the INSTALLED_APPS list. Next, you declare the models required for the new app. Here, you need to create the database tables required for the new app. The makemigrations Command Let us add a new model in the models.py module as follows − from django.db import models # Create your models here. class Dreamreal(models.Model): website = models.CharField(max_length=50) mail = models.CharField(max_length=50) name = models.CharField(max_length=50) phonenumber = models.IntegerField() def __str__(self): return “Website: {} Email: {} Name: {} Ph.: {}”.format(self.website, self.mail, self.name, self.phonenumber) class Meta: db_table = “dreamreal” To propagate the new model in the database, run the makemigrations command − python manage.py makemigrations A migrations script 0001_initial.py will be created in the migrations folder. It contains a Migrations class. The migrate command as used initially, uses this script to create a new table in the database that has been configured in the DATABASES section of settings.py − Python manage.py migrate Eventually, you decide to add a new model class named Employee, as given below − class Employee(models.Model): eid = models.CharField(max_length=20) ename = models.CharField(max_length=100) eemail = models.EmailField() econtact = models.CharField(max_length=15) class Meta: db_table = “employee” When you run the makemigrations command again, it creates the second migration script − D:workspacemyproject> python manage.py makemigrations myapp Migrations for ”myapp”: myappmigrations002_employee.py – Create model Employee The new migration file 0002_employee.py is applied with migrate command − D:workspacemyproject> python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, myapp, sessions Running migrations: Applying myapp.0002_employee… OK If you check in the database structure, the employee table can be found in it. If you feel it necessary to change the structure of any of the models, you need to run the migrations again. We drop the email field and add the salary field. class Employee(models.Model): eid = models.CharField(max_length=20) ename = models.CharField(max_length=100) econtact = models.CharField(max_length=15) salary = models.IntegerField() class Meta: db_table = “employee” Run the makemigrations command again. D:workspacemyproject> python manage.py makemigrations myapp Migrations for ”myapp”: myappmigrations003_remove_employee_eemail_employee_salary.py – Remove field eemail from employee – Add field salary to employee The showmigrations Command The showmigrations command shows the list of migrations scripts generated so far, with the migrations already applied showing “X” mark. python manage.py showmigrations myapp [X] 0001_initial [X] 0002_employee [ ] 0003_remove_employee_eemail_employee_salary Run the migrate command again to effect the changes to employee table − D:workspacemyproject> python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, myapp, sessions Running migrations: Applying myapp.0003_remove_employee_eemail_employee_salary… OK How to Roll Back the Changes? If you want to roll back the recent changes to the employee table and restore the state of 0002_mployee.py script, D:workspacemyproject> python manage.py migrate myapp 0002_employee Operations to perform: Target specific migration: 0002_employee, from myapp Running migrations: Rendering model states… DONE Unapplying myapp.0003_remove_employee_eemail_employee_salary… OK Go back and change the structure to confirm that the employee table structure is restored. Print Page Previous Next Advertisements ”;
Django – Basics
Django – Basics ”; Previous Next Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Django makes it easier to build better web apps quickly and with less code. Note − Django is a registered trademark of the Django Software Foundation, and is licensed under BSD License. History of Django 2003 − Started by Adrian Holovaty and Simon Willison as an internal project at the Lawrence Journal-World newspaper. 2005 − Released July 2005 and named it Django, after the jazz guitarist Django Reinhardt. 2005 − Mature enough to handle several high-traffic sites. Current − Django is now an open source project with contributors across the world. Django – Design Philosophies Django comes with the following design philosophies − Loosely Coupled − Django aims to make each element of its stack independent of the others. Less Coding − Less code so in turn a quick development. Don”t Repeat Yourself (DRY) − Everything should be developed only in exactly one place instead of repeating it again and again. Fast Development − Django”s philosophy is to do all it can to facilitate hyper-fast development. Clean Design − Django strictly maintains a clean design throughout its own code and makes it easy to follow best web-development practices. Advantages of Django Here are few advantages of using Django which can be listed out here − Object-Relational Mapping (ORM) Support − Django provides a bridge between the data model and the database engine, and supports a large set of database systems including MySQL, Oracle, Postgres, etc. Django also supports NoSQL database through Django-nonrel fork. For now, the only NoSQL databases supported are MongoDB and google app engine. Multilingual Support − Django supports multilingual websites through its built-in internationalization system. So you can develop your website, which would support multiple languages. Framework Support − Django has built-in support for Ajax, RSS, Caching and various other frameworks. Administration GUI − Django provides a nice ready-to-use user interface for administrative activities. Development Environment − Django comes with a lightweight web server to facilitate end-to-end application development and testing. Print Page Previous Next Advertisements ”;