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 987659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:30:53+00:00 2026-05-16T05:30:53+00:00

I want to be able to put certain configuration information in my settings.py file

  • 0

I want to be able to put certain configuration information in my settings.py file – things like the site name, site url, etc.

If I do this, how can I then access those settings in templates?

Thanks

  • 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-05-16T05:30:54+00:00Added an answer on May 16, 2026 at 5:30 am

    Let’s say in your settings.py file you have:

    SITE_URL='www.mydomain.tld/somewhere/'
    SITE_NAME='My site'
    

    If you need that in just one or two views:

    from django.shortcuts import render_to_response
    from django.conf import settings
    
    def my_view(request, ...):
        response_dict = {
            'site_name': settings.SITE_NAME,
            'site_url': settings.SITE_URL,
        }
        ...
        return render_to_response('my_template_dir/my_template.html', response_dict)
    

    If you need to access these across a lot of apps and/or views, you can write a context processor to save code:

    James has a tutorial on this
    online.

    Some useful information on the when and if of context processors is available on this very site
    here.

    Inside your my_context_processors.py file you would:

    from django.conf import settings
    
    def some_context_processor(request):
        my_dict = {
            'site_url': settings.SITE_URL,
            'site_name': settings.SITE_NAME,
        }
    
        return my_dict
    

    Back in your settings.py, activate it by doing:

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...
    
        # yours
        'my_context_processors.some_context_processor',
    )
    

    In your views.py, make a view use it like so:

    from django.shortcuts import render_to_response
    from django.template import RequestContext
    
    def my_view(request, ...):  
        response_dict = RequestContext(request)
        ...
        # you can still still add variables that specific only to this view
        response_dict['some_var_only_in_this_view'] = 42
        ...
        return render_to_response('my_template_dir/my_template.html', response_dict)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to add and update certain information. Now it was
I am using Eclipse 3.4. I want to be able to put a breakpoint
I'm using $this->redirect('route', array('id' => $id)); but I need to be able to put
I want to take in a certain format of one text file. After the
I'd like to be able to put in a GPS coordinate (latitude and longitude)
I have an application in whioch I want certain operation logs to be put
I'm using LaTeX and BibTeX for an article, and I want to able to
Want to be able to provide a search interface for a collection of objects
I want to be able to take an image that i have already captured
I want to be able to replicate only the folder structure (not the contents)

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.