Questions tagged [django-context]

django-context refers to the special django.template.Context class used for passing data from the view to the template

171 questions
0
votes
3 answers

Best practices for passing model names as strings

I have two different models that I would like to filter similarly by a common field name at different times, so i've written a single context function that handles both models by taking a string as an argument to use as the model name. Right now…
skzryzg
  • 1,020
  • 8
  • 25
0
votes
1 answer

why is context processor adding to every view in django?

I have created a context processor so that I have a variable passed to all of my templates. My settings.py looks like this: TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', …
Atma
  • 29,141
  • 56
  • 198
  • 299
0
votes
1 answer

Passing django contexts between apps

So I'm fairly new to Django and am creating some simple websites. Right now I am trying to create a website that can be used to host some of my other apps. At the moment, the main site renders the navbar by passing a dictionary of names/urls to a…
user1539179
  • 1,835
  • 2
  • 16
  • 28
0
votes
1 answer

How to pass parameters to HttpResponseRequest elsewhere than in the url in Django

I'm trying to code a form in Django that redirect to itself, the display changing according to what you entered in the form. To do so, I retrieve the POST data in the backend and want to display a message this way: {% if message %} {{ message }} {%…
Robin
  • 9,415
  • 3
  • 34
  • 45
0
votes
1 answer

Django: How can i get the url of a template by giving the namespace?

While i'm rendering a template i would like to retrieve the url of the template by giving the namespace value and not the path. For example instead of this: return render(request, 'base/index.html', {'user':name}) i would like to be able to do the…
CodeArtist
  • 5,534
  • 8
  • 40
  • 65
0
votes
1 answer

How to implement a custom global login / logout feature in django

I am trying to implement a custom login / logout feature. My requirements are a little different than the in-built django log-in feature. So, I have to implement this feature in a way where I can just put a value 0 / 1 in the database to check if…
First Blood
  • 235
  • 1
  • 7
  • 21
0
votes
1 answer

Django context processors and middleware

I'm trying to set a context variable in my custom context_processor which I craft using a request variable. The request variable I'm trying to use is set in my custom middleware. However I get the following error: AttributeError: 'WSGIRequest'…
heri0n
  • 1,459
  • 3
  • 19
  • 33
0
votes
1 answer

Django - Context not available in template tag include

0
votes
3 answers

Django - Extra context in django-registration activation email

I'm using django-registration for a project of mine. I'd like to add some extra contextual data to the template used for email activation. Looking into the register view source, I cannot figure out how to do it. Any idea ?
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
0
votes
2 answers

django automatically pass context to specific templates only

I have context in a dict: ### settings.py. ### CONTEXT = {'a':'b'} And two templates that use that context t1.html and t2.html: ### t1.html ### {{ a }} ### t2.html ### {{ a }} Both are meant to be included inside many other templates as: ###…
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
0
votes
1 answer

Joomla Session Variables

In Django there is a method called getContext, which retrieves session data, template vars, and everything in the correct "context". I am now programming in Joomla, and making some components and for debugging I am looking for a way to see all the…
0
votes
1 answer

django ajax context

How do I use upload_response below in my html/jquery to check if it is true or not, and display some text accordingly without going to a new page? fileupload.py file: template = loader.get_template('start_interview.html') context = Context({…
user1678031
  • 2,925
  • 2
  • 16
  • 15
0
votes
1 answer

session variable or extra context?

I need to have a few variables accessible on almost every view. I think I can see how to do it either using a context processor and "extra context" values, or by using session variables. Are there advantages and disadvantages? Which approach…
mb52089
  • 872
  • 2
  • 10
  • 24
0
votes
2 answers

What is the simplest language which support template&context mechanism?

I need to find the easiest way to automatically build ebooks from downloaded articles. I want to automatically generate TOC, which will be based on HTML template. I know that python django has template & context mechanism, however django is a little…
noisy
  • 6,495
  • 10
  • 50
  • 92
0
votes
1 answer

the dictionary defined in context processor doesn't refresh without page reload?

I created a custom context processor which returns "unread_messages_count".Now when I'm updating it on the template using: var update_message_count = setInterval(function(){ $('a#check_messages').text('{{…
Rajat Saxena
  • 3,834
  • 5
  • 45
  • 63
1 2 3
11
12