Integrating Twitter bootstrap with Django in simple steps

Assuming you have downloaded Twitter bootstrap and a simple Django project is up and running, please follow the below 3 steps to integrate Twitter bootstrap with Django.

STEP 1: Copy twitter bootstrap files & templates as below in your Django project folder

  • /project_root/template/bootstrap
  • /project_root/template/example.html

STEP 2: Set the values of STATIC_URL, STATICFILES_DIRS, INSTALLED_APPS as given below in settings.py

STATIC_URL = ‘/static/’

#Absolute path to your twitter bootstrap directory
STATICFILES_DIRS = ( ‘/home/project_root/template/bootstrap’, )

#Make sure ‘django.contrib.staticfiles’ is uncommented
INSTALLED_APPS = (
.
.
‘django.contrib.staticfiles’,
.
.
)

TEMPLATE_DIRS = (‘/home/project_root/template’,)

STEP 3: In your view class add the below two entries

#import RequestContext
from django.template import RequestContext

#pass context_instance=RequestContext(request) as 3rd argument
return render_to_response(‘example.html’,{},context_instance=RequestContext(request))

Screenshot below:

Image

Advertisements

One thought on “Integrating Twitter bootstrap with Django in simple steps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s