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
6
votes
2 answers
django url parameters into context_processor
I have this Django Url:
url( r'^(?P.*)/(?P.*)/(?P.*)/$', 'app.views.view_1' ),
Now, "language", "shop", "brand" are all parameters into my url and I want to read them into my custom Django Context Processor. How can I do…

Gabriele Morgante
- 69
- 5
4
votes
3 answers
Django template context multiple views
I'm running Idios, a profile app, and I would like to make the profiles in my app on top of idios (i.e. keep idios pip-installable, without modifying the app itself).
The problem is, the profile view is written in the idios app, using the…

wrought
- 43
- 5
4
votes
1 answer
How do I pass context to a template without actually specifying it in all views?
I have a few views and they all work good and all use templates that extend one base template that outputs the core HTML, the header, footer, navigation and so on. Happy family.
now, I want to play with sessions on the pages and since you can't get…

abolotnov
- 4,282
- 9
- 56
- 88
4
votes
2 answers
Django - print all objects attribute values
HTML
{% for field in fields %}
{{ field }}
{% endfor %}
{% for well in well_info %}
{{ well.api }}
{{ well.well_name }}
{{…

Eric Kim
- 2,493
- 6
- 33
- 69
4
votes
4 answers
Django Template
I am doing a Django tutorial on Templates. I am currently at this code:
from django.template import Template, Context
>>> person = {'name': 'Sally', 'age': '43'}
>>> t = Template('{{ person.name }} is {{ person.age }} years old.')
>>> c =…

MacPython
- 17,901
- 10
- 42
- 48
4
votes
3 answers
How can my Django views know which template to render, or whether to return JSON?
Our site can be accessed from a full browser, from mobile browsers, and from a custom iPhone app. Since the logic is mostly the same regardless of the client, we're using the same views to process all types of requests. But at the bottom of every…

claymation
- 2,475
- 4
- 27
- 36
4
votes
1 answer
Setting initial formfield value from context data in Django class based view
I've got an activation url that carries the activation key ( /user/activate/123123123 ). That works without any issue. get_context_data can plop it into the template fine. What I want to do is have it as an initial value for the key field so the…

meteorainer
- 913
- 8
- 21
4
votes
2 answers
Pythonize Me: how to manage caller context variables in Python? (Python/Django)
I'm trying to refactor a fairly hefty view function in Django. There are too many variables floating around and it's a huge function.
Ideally, I want to modularize the view into logical functions.
However, I have to pass the function context around…

vaughnkoch
- 1,779
- 2
- 13
- 17
3
votes
1 answer
Creating singletons in django, or any other way for global, per-request available object
While developing "widgets" (objects, which - rendered - use some custom javascript files), I faced the need of creating kind of "included-scripts-manager" (to avoid double inclusion of same JS file when more than one widget is rendered for the…

migajek
- 8,524
- 15
- 77
- 116
3
votes
2 answers
Django messages framework not working in template loop
I recently upgraded to Django 1.3 and I want to start using the Messages system.
I have added my Middleware, Template context processors and also messages into the INSTALLED_APPS
MIDDLEWARE_CLASSES = (
…

ApPeL
- 4,801
- 9
- 47
- 84
3
votes
1 answer
django change_form.html
I'd like to pass an argument {{x}}to my custom file change_form.html, which is located in /home/django/project/app/template/admin/change_form.html. I found this code but it doesn't work:
class MyModelAdmin(admin.ModelAdmin):
# A template for a…

paveu
- 31
- 1
- 2
3
votes
1 answer
How do I set the "next" context variable in Django so I can redirect my user to the appropriate page?
I'm aware that there is a context variable called "next" which allows you to specify the URL to redirect to after a page, which is commonly used when you want to redirect a user to a login page, then redirect them back to the page they were at…
user4743662
3
votes
2 answers
When to use context processor
I have a site on which I'm including a userBox with some data shown for each logged user (your name, avatar etc). From what I already know about django it seems obvious, that I should add query for user to context processor (so that I can…

sasquatch90
- 133
- 3
- 9
3
votes
1 answer
django navbar template - tags
I have created 2 navbars one for blog and one for the main app. I use include tag to introduce navbar into templates. "extends base.html" is also used however, navbar is not included in the base file and as mentioned above is introduced as include…

Uma
- 689
- 2
- 12
- 35
3
votes
1 answer
Passing context between templatetags, django
I am using django to create a web-application.
I have created a template in where I load a templatetag. In this templatetag I load another templatetag. From the template I pass context to the first templatetag, but the context is not available from…
user299696