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
1 answer

is that possible to access caller principal in model class in django?

Is that possible to access user principal in model class? For example, in java, in ejb class, there is ejbcontext variable always available which gives you caller details (authenticated user) I am wondering are there any way to get this in django in…
devharb
  • 211
  • 2
  • 4
0
votes
1 answer

Python/Django universal method passed to template engine

I have a large Django Project that has hundreds of views already. I am creating a tasks feature where users are able to complete specific tasks associated with the specific application in the project they are using. I have multiple interfaces (aka…
ViaTech
  • 2,143
  • 1
  • 16
  • 51
0
votes
0 answers

In django how to pass RequestContext from the url declaration?

I've some url that I want to render a template without creating a view for each one, but inside I need a form with the csrf tag, so when the user post the form I get no csrf token becouse the template have no RequestContext render on it. How can I…
Mariano DAngelo
  • 920
  • 5
  • 18
  • 39
0
votes
1 answer

how to pass django context to create react app

I set up create-react-app with django following this example. The webpage get passed in the views like this: def get(self, request): try: with open(os.path.join(settings.REACT_APP_DIR, 'build', 'index.html')) as f: …
Tom
  • 2,545
  • 5
  • 31
  • 71
0
votes
1 answer

difference between using super() and super(ViewName,self)

I have been using in generic views (CBVs) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) but I've noticed that people here do: context = super(ClassViewName,self).get_context_data(**kwargs) is there is a…
0
votes
1 answer

Multiple vs one big context_processor

I have multiple context processor and in each I have to request the user. Each of these look like this: def UploadForm(request): user = request.user Uplo = UploadForm(request.POST or None, initial={user}) return {'Uplo': Uplo} I saw that this…
hansTheFranz
  • 2,511
  • 4
  • 19
  • 35
0
votes
2 answers

How to supply a QuerySet to an included template?

I have a simple Django application for a magazine website, with a sidebar that shows links for recent issues. The sidebar is its own template, which I then include into other pages. I want the Queryset for recent issues to be part of the sidebar…
0
votes
1 answer

django - context processors return error

I've added the following function in context_processors.py. but when i go to index url, return me error. it's a natural error. because we do not have a date arguments in index. is there any way to prevent this error to be displayed? sample_path =…
shahin
  • 159
  • 1
  • 7
0
votes
1 answer

Django 1.10 - Maintaining context object information

My question is, is there a way to maintain the context object over multiple views? Say you are at the home page, you click a link to go to a specific part of the application but you want to maintain the context information as to not excessively…
Måns Thörnvik
  • 1,038
  • 2
  • 10
  • 22
0
votes
1 answer

Django: Context processor error for anonymous user

Hi I have a model which stores users actions. This model is used for showing notifications to logged in users. Now the issue is code works fine with logged in users, however if I open homepage of application after logout, following error…
Pulkit Sharma
  • 264
  • 1
  • 2
  • 18
0
votes
0 answers

Proper way to retrieve middleware values

I'm trying to retrieve some loading times per view and displaying it in the page. To do so I'm using a middleware and a context_processor setup but I can't find the way to retrieve this values to the context of the view. Here is the example: I've…
Rod
  • 90
  • 8
0
votes
1 answer

Override template Block directly from view Django

hi i am trying to build flat pages in django here i would like to override the base html
{% block container %} {% block content %}{% endblock content %} {%…
Amandeep Singh
  • 305
  • 2
  • 11
0
votes
1 answer

How can I retrieve a list from context in my django template

I have a detail view with one model Room, in get_context_data method I add to my context another queryset of objects from second model:Worker class RoomView(DetailView): template_name = 'detail.html' model = Room context_object_name =…
kapitoshka
  • 45
  • 1
  • 10
0
votes
1 answer

Django Context processors missing while they are in the settings

This is what i get in my terminal when i start the server locally: Required context processor django_facebook.context_processors.facebook wasnt found Required context processor django.core.context_processors.request wasnt…
Tony
  • 2,382
  • 7
  • 32
  • 51
0
votes
1 answer

CSRF token not rendered if using Context({dict}) vs just {dict}

Does anyone know why the following renders my template ok: c= {'render_form' : form } return render(request, 'page1.html', c) but the following does not render the csrf token: c= Context({'render_form' : form}) return render(request, 'page1.html',…
woodduck
  • 339
  • 2
  • 12