django-context refers to the special django.template.Context class used for passing data from the view to the template
Questions tagged [django-context]
171 questions
1
vote
1 answer
Django ImportError No module named 'catalog.context_processors'
I'm a Django beginner and I encounter an issue with django context_processors.
I want use a queryset in all my template for generate a menu.
But I get this error when I try to reach this page http://mysite/catalog which calls my…

epi.log
- 361
- 4
- 18
1
vote
1 answer
Django Thread-Safety for templatetags
I am coming here, because I have a question about Django and Thread. I read the documentation http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#template-tag-thread-safety and I would like to now if the next code could be impacted…

Acti67
- 577
- 4
- 11
1
vote
2 answers
How to update Context processor variables using ajax request, without refreshing page
Currently am displaying notifications count on header for new notifications, they have is_read = False, I want to update is_read = True and remove notifications count, Here is what i am doing
context_processor
def notification(request):
…

user1752752
- 45
- 2
1
vote
1 answer
django update view and passing context
I have a update view:
class GeneralUserUpdateView(UpdateView):
model = GeneralUser
form_class = GeneralUserChangeForm
template_name = "general_user_change.html"
def dispatch(self, *args, **kwargs):
return…

gamer
- 5,673
- 13
- 58
- 91
1
vote
2 answers
Django template doesn't seem to be getting my context dictionary
The following template renders with the image from the static directory appearing, but myvar doesn't show up. Somehow {{STATIC_URL}} is being evaluated correctly, but {{myvar}} is empty. What am I missing?
views.py
def home(request):
return…

Isaac Ray
- 1,351
- 9
- 17
1
vote
2 answers
Django: request object to template context transparancy
I want to include an initialized data structure in my request object, making it accessible in the context object from my templates. What I'm doing right now is passing it manually and tiresome within all my views:
render_to_response(...., ( {'menu':…

Anders
- 856
- 1
- 7
- 14
1
vote
1 answer
Django display a view in every page
I want to run my for loop in every page. I have same of the code below in my views.py.
def hepsi(request):
basliklar = Baslik.objects.filter(active=True).order_by('-updated')
return render_to_response("base.html", locals(),…

malisit
- 1,253
- 2
- 17
- 36
1
vote
1 answer
extra_context function for simple generic view in django
I have my page where I have my posts list, and I also want to have sidebar with suggestions. I used generic ListView for my posts, and needed to pass suggestions somehow so I used extra_context which should(?) work like that according to few…

user3691902
- 13
- 3
1
vote
1 answer
How pass the request object in inclusion tag?
I am using django 1.5
I want pass the request object to my inclusion tag, however get a error, Key Error.
My view is:
class IglesiaCreateView(CreateView):
model = Iglesia
template_name = 'iglesia/iglesia_form.html'
success_url =…

lflorespy
- 27
- 5
1
vote
3 answers
Is there a list of default template variables in django?
I noticed that the django templates already have certain variables passed to it without you having to send any data. For instance, the 'user' variable can be called without sending any 'user' data to the template when rendering.
Is there somewhere…

Steven Rogers
- 1,874
- 5
- 25
- 48
1
vote
1 answer
Django: which context belongs to which template
I'm on the verge of testing attributes in response.context with django's own test client (in django.test.client).
I get back 5 response.context's. As it seems one for each template part, because when I remove a nested template part (e.g: {% include…

GerardJP
- 985
- 2
- 9
- 20
1
vote
1 answer
Unable to reverse view in middleware
I'm trying to do catch a missing variable in a Django rotue with middleware - however I am unable to reverse the URL as Django cannot find the view (even though it exists in urlconf). For example:
With this route:
# matches /test and…

Ross
- 46,186
- 39
- 120
- 173
1
vote
3 answers
Context Processor for Django Site
I'm builing a wedding website creator (no judgement please).
Almost every view needs to call a Wedding.objects.get(id=wedding_id) and then pass it to the template as part of the variables.
Seems like this is a good use for a custom context…

Brenden
- 8,264
- 14
- 48
- 78
1
vote
1 answer
How to include my base template with custom context in Django comment templates?
I have included Django comments framework in my project, and added custom templates to include my base template instead of the default one.
However, in my base template, there are a few url template tags with dynamic parameters:
{% url galleries…

yossarian
- 13
- 3
1
vote
2 answers
Django context processor made available without a view
I want to query all products and load them in a dict with category-id as key using a context processor. Then I want to make this dict available in a template, in order to send it to a template tag as argument.
Is it possible to use the context…

blaise
- 383
- 1
- 5
- 16