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
2
votes
4 answers
render_to_response always pass a variable
I'm finding myself always passing a 'user' variable to every call to render_to_response
A lot of my renders looks like this
return render_to_response('some/template', {'my':context,'user':user})
Is there a way to automatically send this 'user'…

dotty
- 40,405
- 66
- 150
- 195
2
votes
1 answer
Implementing a bread crumb in Django
I'm writing an application in Django and I want every page to contain a bread crumb.
The bread crumb needs to look like "Group A > Group A.1 > Group A.1.1". On each page the bread crumb will be different.
Group is a model. The thing confusing me is…

hekevintran
- 22,822
- 32
- 111
- 180
2
votes
1 answer
Django last visited urls list
I'm writing django-based forum, and i've decided it would be suitable for user to browse his last pages. Also, user tracking middleware can be a good aid for suggestions, and so on.
I think, the easiest way to do it is to use the Django Middleware,…

night-crawler
- 1,409
- 1
- 26
- 39
2
votes
6 answers
Django custom context processor being called twice per request
I created a simple custom context processor that needs to only be run
once per request. After putting in some logging hooks I found that it
is being called twice per request.
Is this a known "feature" that a missed in the docs?
Is it related to the…
user178884
2
votes
3 answers
How to inject template context variable only if it doesn't exist
I have a base_template.html that uses a context variable my_context_var. All of my other templates extends this base template. Can you help me answer one of these questions? (They are just different ways to look at the same underlying problem)
How…

lastoneisbearfood
- 3,955
- 5
- 26
- 25
1
vote
1 answer
how do I pass user profile data with extra context in class-based generic views?
I have model:
class Schedule(models.Model):
begins_at = models.DateTimeField()
instructor = models.ForeignKey(User)
user profile:
class InstructorProfile(models.Model):
user = models.ForeignKey(User, unique=True)
level =…

Vlad T.
- 2,568
- 3
- 26
- 40
1
vote
3 answers
User Context in Django
I am having problems with user authentication for my django site. I have a log-in screen that seems to work. When the user clicks log-in, I call the django.contrib.auth.login and it seems to work fine. However on subsequent pages have no…

codingJoe
- 4,713
- 9
- 47
- 61
1
vote
1 answer
Passing Extra context to ListViews in Django
Can anyone please tell me how I can pass the "query" on my ListView as a context while at the same time keeping "search_results" as a context_object_name? I just can't get my head around it:
class SearchResulView(ListView):
model = Product
…

Monk BR
- 21
- 3
1
vote
0 answers
Navbar problem with views context, when using slug or PK. (Django)
The slug will only work on HomeView if I add it to the HomeViews context, but I only want to add it one time, I don't want to add it to every view, but I want it to work on every view.
Is there anyway I can do this?
app2/models.py
from django.db…

AnonymousUser
- 690
- 7
- 26
1
vote
1 answer
Pass context to ModelSerializer field in Django Rest Framework
I am trying to pass a variable from my view to the serializer via context. The Serializer should be able to get the context variable and use it in a field that contains a nested serializer.
Since the nested serializer field cannot be read_only, I…

Fabio Magarelli
- 1,031
- 4
- 14
- 47
1
vote
0 answers
How to setup menu data in Context_processor in Django?
I have category and subcategory store in my database, and subcategory is related to category, I have multiple pages on my website, but I am able to display category in the menu on some pages, but I want to display on all pages, so I found the…

Robot
- 76
- 1
- 9
1
vote
1 answer
Django: proper way to get context data from another view
I have a menu that its content is obtained from a view, and that menu is in every view. Is there a proper way to get its context data to all my views without having to code again the same thing in every view?
I was thinking returning that context on…

Luis Méndez
- 25
- 4
1
vote
2 answers
Django context variable in the navigation bar - correct href assignment?
What is the correct assignment of context variables in the navigation bar? My Django example is:
in view.py:
from django.shortcuts import render
from django.http import HttpResponse
context_navigation = {
'Link1' : 'Blog',
…

pyano
- 1,885
- 10
- 28
1
vote
1 answer
Pyjamas and Django static files setup
I am somewhat new to both web development and new to the Django and Pyjamas frameworks. So I appreciate any patience offered to me as I learn.
I am setting up Django and Pyjamas to work together, JSONRPC Client/Server + Django templates.
I have the…

Shattered1113
- 21
- 4
1
vote
1 answer
KeyError in my view context when trying to dynamically call a view in Django
I try to dynamically call a view in Django with this url configuration :
url(r'^niveau/(?P\d+)/(?P\w+)/$', views.switcher , name='vue_niveau')
Then in my view.py, i have :
def switcher(request, niveau_id, channel):
if channel ==…

Nnomuas
- 63
- 5