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
1
vote
2 answers

'NoneType' object is not iterable - issue with context in Django

I have this models.py: class dateEvent(models.Model): venue = models.ForeignKey(Venue, on_delete=models.CASCADE) event = models.ForeignKey('Event', on_delete=models.CASCADE) start_date_time = models.DateTimeField(auto_now=False,…
HBMCS
  • 686
  • 5
  • 25
1
vote
0 answers

Django - Correct Use of Mixins with CBVs

I just started to shift from function-based views to class-based views, as I realize more and more the benefits of the latter, especially regarding the modularity that you can achieve via mixins. However, as CBVs and Mixins are still quite new to…
1
vote
1 answer

Django context processors model not found

I am trying to implement a context_processor in Django via a custom app. I am failing due to Module not found error. My app name is brand. My context processer looks like this: from .models import ContactDetail def contact(request): contact =…
Daniel Tate
  • 2,075
  • 4
  • 24
  • 50
1
vote
2 answers

Django custom tag 'takes_context'

I`m new with django (came from Grails), especially with all those custom tags that you have to deal with, instead of writing your variables directly inside the templates. Well, what I need to do was something really simple, but for some reason is…
mateusmaso
  • 7,843
  • 6
  • 41
  • 54
1
vote
1 answer

Django template context variables don't show

I have a custom article.html template that is overriding the default article.html template that comes with the aldryn newsblog plugin. In this template I have 2 lines to include some custom functionality: {% include 'comment_form.html' %} {% include…
pinksharpii
  • 527
  • 1
  • 8
  • 18
1
vote
1 answer

Alternative to blocktrans tag with long `with` clause

Context I'm trying to use the django template engine to render translatable part of a page using variable from the context. Specifically, this is my use case {% blocktrans trimmed with type=training.type title=training.title city=training.city…
1
vote
1 answer

Django - how to pass context in base.html?

I have well_list.html that looks like this: Clicking on one of the rows will lead to this page: The above page uses two html files: base.html + contextual_main.html. Base has sidebar navigation, and the latter one extends from the base. In my…
Eric Kim
  • 2,493
  • 6
  • 33
  • 69
1
vote
1 answer

What is the difference between context.push() and context.update() in Django Context

From the documentation, I understand that the context object is a stack. Then what are push() and update() doing with respect to this code segment? It is stated in the doc that push() and update() are similar but update() takes a dictionary as…
1
vote
0 answers

Django : Context processors

What is the mechanics behind context processors in Django? I have used them before, but if someone asks me to teach them what context processors are about, I probably could not answer. This is from Django documentation: context_processors is a…
scharette
  • 9,437
  • 8
  • 33
  • 67
1
vote
1 answer

Django Context processors not working?

I have made one Django context processor which is not working...and it is also showing warning messages.First will show you the warning message:- WARNINGS: ?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the…
Abi Waqas
  • 299
  • 1
  • 13
1
vote
2 answers

Django: Does DRY fundamentally conflict with logic separation?

This is similar to this question: How to use method parameters in a Django template? I understand (and agree with and appreciate) the basic django philosophy of separation of business logic from presentation logic. However, at times it seems to make…
jMyles
  • 11,772
  • 6
  • 42
  • 56
1
vote
1 answer

Passenger Django custom variable in settings.py is not passed to template

I would like disqus comments disabled when my django app runs locally or on the test server. So in my Django settings.py I am using: DEBUG = True DISQUS = False Now in my django blog_post.html template I have an IF statement: {% if DISQUS %} …
ionescu77
  • 1,150
  • 10
  • 14
1
vote
0 answers

Access custom context processor in django 1.9

I am using django 1.9. In my settings file, I have added my apps custom context processor as such: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, "templates")], …
user875139
  • 1,599
  • 4
  • 23
  • 44
1
vote
1 answer

How to pass argument on custom context_processors.py?

Is it possible to pass some argument from dynamic urls (I have ^c/(?P\w+)/^) to custom context_processors? views.py (I pass username from url to RequestContext) def client_profile(request, username): # .... some context return…
A. Fynn
  • 39
  • 6
1
vote
2 answers

Conditional context processor for authenticated users

I have a context processor returning list of users friends. I'd like it to return the dictionary of friends only if user is logged in, because currently I have clean database without any users and I'm getting error : Exception Type: DoesNotExist at…
muntu
  • 27
  • 1
  • 5