Using Django settings in templates




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
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](http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/).


Some useful information on the when and if of context processors is available on this very site 
[here](https://stackoverflow.com/questions/831301/when-is-it-appropriate-to-use-django-context-processors).


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)

```
hi chris, 
if you use relations api, you may set properties field in your query. in this field you should set the names of the properties which values must be retrieved from the server. the argument should be a string in the following format: "propertyname1, propertyname2, , , propertynamen" , wher… my disney experience is a magical tool, so let’s get that reservation linked to your account so you can start planning! sign in to your disney account, visit my plans, and under resort hotel select link a reservation. you will need to provide the confirmation number and the last name on the reservation to retrieve your resort reservation or vacation package details. hi paul,

i believe the financial reporting covers in quite a lot of detail exactly what you are looking for.

from what i can tell you aren’t using templates in your tables…

[[image]](https://forum.enterprisedna.co/uploads/db7134/original/2x/5/559a333f85c159c8d9bec9235ca5c45997d08858.png "image")

if you want to get a certain order and custom table then you really need to use the template approach covered in t… oh, sorry everyone. lemme try to help.

fair warning: it’s well after midnight and i should be asleep. i haven’t tested this config but i have verified that it loads successfully.

this is probably what you want:

localhost

templates

encode gzip

file\_server

root * /home/html

php\_fastcgi unix//tmp/p… hey [@web2033](/u/web2033), you can see more about how to correctly configure functions here:

[image]

[configure and deploy functions](https://docs.netlify.com/functions/configure-and-deploy/)

netlify builds, deploys, and hosts your front end.

learn how to get started, see examples, and view documentation for the modern web platform.

… use the query string to pass the venue id to the generic venue display page, make your <a> tags ref that page with "?id=xxx" at the end, from the venue page fetch that xxx value and query your db for that specific venue, and display that venue's fields as you like.


$myvar = $\_GET['id']; and thus  

Select * FROM table WHERE field='$myvar' From the [Library Reference](http://docs.python.org/2/library/stdtypes.html#set-types-set-frozenset):



> 
> The set type is mutable — the contents can be changed using methods like add() and remove().
> 
> 
> sorry i took so long to respond on this post. i’ve had a busy week! so i found the issue. in my template for endpoints i realized i accidentally set them to provision using the external ip address of my pbx. changed it to internal and this fixed my issues :stuck\_out\_tongue: well, transferring your data and transferring that and your settings are different. data, such as music, letters, video, pictures can burn to disk or copy/move to external drive. installed applications won't go, you'll have to reinstall from disk or download. on the other hand, you can transfer settings, favorites etc. use files and settings transfer wizard. or laplink software and cable. > 
> i want to create ap application which generates popup alerts at the day of event ocurs as well as a day before the event will occur in a specific time interval as well.. events are stored in database and they are all date fields .. so i want to link those fields to create popups .. help me .
> 
> 
> 


In order to help you, you must first provide us with what you have achieved. We do not write code for you, simply correct and enlighten on mistakes.