Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:29:32+00:00 2026-06-17T22:29:32+00:00

I want to use Twitter Bootstrap in my Django application and for this purpose

  • 0

I want to use Twitter Bootstrap in my Django application and for this purpose modified the template in the following way:

<!DOCTYPE html>

<html>
<head>
    <title>{{ genplan.name }}</title>
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
    <h1>{{ genplan.name }}</h1>
    <ol>
        {% for cur_goal in goals %}
            <li>{{ cur_goal.description }}</li>
        {% endfor %}
    </ol>

    ...
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="js/bootstrap.min.js"></script>
</body>
</html>

MEDIA_ROOT and MEDIA_URL are set correctly.

MEDIA_ROOT = 'D:/dev/ccp/ccp-gp/media'
MEDIA_URL = '/media/'

However, nothing has changed after I added the Bootstrap stylesheets (the look of that page didn’t change) and I suppose that Django doesn’t find the Bootstrap resources.

What may have caused this problem?

Update 1:

When I use this code in urls.py

urlpatterns = patterns('',
    (r'^$', 'ccp_gp.general_plans.views.home'),     (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT})     )

Python complains about undefined settings variable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:29:33+00:00Added an answer on June 17, 2026 at 10:29 pm

    You need to use the MEDIA_URL when loading the css and js:

    <link href="{{ MEDIA_URL }}css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="{{ MEDIA_URL }}js/bootstrap.min.js"></script>
    

    Unless you have to use an old Django version which does not come with the static files app I would recommend to use STATIC_URL instead and put the files into the static directory of your app.

    <link href="{{ STATIC_URL }}css/bootstrap.min.css" rel="stylesheet" media="screen">
    <script src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
    

    As stated in the comments your {{ MEDIA_URL }} is empty. In order to fix that make sure that the TEMPLATE_CONTEXT_PROCESSORS settings contains the ‘static’ and ‘media’ context processor. Unless you have modified the TEMPLATE_CONTEXT_PROCESSORS settings this is already the case.

    The template context processors are only used when rendering a template with the RequestContext. Starting with Django 1.3 the best way to do this is by using a TemplateResponse.

    For example:

    from django.template.response import TemplateResponse
    
    def index(request):
        genplan = ...
        goals = ...
        return TemplateResponse(request, 'index.html', {
            'genplan': genplan,
            'goals': goals,
        })
    

    For the files in the MEDIA_DIR to be delivered via the the development server (manage.py runserver) you can add the following code to your urls.py:

    from django.conf import settings
    
    if settings.DEBUG:
        urlpatterns += (
            url(r'^media/(.*)$', 'django.views.static.serve',
                        {'document_root': settings.MEDIA_ROOT}),
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make an application making use of twitter's bootstrap framework. I have
I want to use twitter bootstrap for some site I am working on. This
I'm using twitter bootstrap in my application. I want to use the typeahead in
I work in IE 9 and want to use Twitter Bootstrap. One of the
I want to use twitter web service in my silverlight application but don't know
Concrete use case: http://jsfiddle.net/MgcDU/271/ There this a twitter bootstrap tabs, and content of the
I want to use the modals from Twitter Bootstrap , but I can't switch
I am using Twitter bootstrap for developing Web pages,Now I want to integrate this
I want to use the twitter bootstrap carousel in a personal project. So far
I'm using Twitter Bootstrap with Jquery. I want to use the TYPEAHEAD function for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.