Re: Why is my Django template not displaying?

2016-06-03 Thread Luis Zárate
Use  plays as a list in form.

You are passing context_list as context object so all variable inside
context_list are available in template but not context_list.

Other option is
return render(request,'live.html',
{"context_list": context_list})


El viernes, 3 de junio de 2016, Dave N 
escribió:
> That absolutely did it James - I thought I was accessing the instance,
but what I needed was to access the template context contents of the
instance. Also, great tip with the django debug toolbar - I've had it
installed, but didn't know how much it actually shows!
>
> On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>>
>> Assuming my model contains data, I have myapp/views.py:
>>
>> from django.template import RequestContext
>> from django.shortcuts import render
>> from .models import History
>> import datetime
>>
>> def live_view(request):
>> context = RequestContext(request)
>> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
>> context_list = {'plays':plays_list}
>> return render(request,'live.html',context_list)
>>
>> myapp/templates/live.html:
>>
>> {% extends 'base.html' %}
>> {% block content %}
>> {% for key, value in context_list.items %}
>> {{ value }}
>> {% endfor %}
>> {% endblock %}
>>
>> myapp/urls.py:
>>
>> from myapp.views import live_view
>> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>>
>> The output is a page that renders only the base.html template, with no
content in the body. What's wrong with my view function or template
rendering? Should I be inheriting from TemplateView?
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyO1F9pkXF_rMbtPeZayHmui3xtsGnBZhN%3Dri0nsM2zJ7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread Dave N
That absolutely did it James - I thought I was accessing the instance, but 
what I needed was to access the template context contents of the instance. 
Also, great tip with the django debug toolbar - I've had it installed, but 
didn't know how much it actually shows!

On Friday, June 3, 2016 at 8:58:33 AM UTC-7, Dave N wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContextfrom django.shortcuts import 
> renderfrom .models import Historyimport datetime
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}{% block content %}{% for key, value in 
> context_list.items %}
> {{ value }}{% endfor %}{% endblock %}
>
> myapp/urls.py:
>
> from myapp.views import live_view
> urlpatterns = [url(r'^live/$', live_view, name="live"),]
>
>
> The output is a page that renders only the base.html template, with no 
> content in the body. What's wrong with my view function or template 
> rendering? Should I be inheriting from TemplateView?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2dc2c249-66bd-4466-bc45-2d5dee2ba4b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why is my Django template not displaying?

2016-06-03 Thread James Schneider
On Jun 3, 2016 8:58 AM, "Dave N"  wrote:
>
> Assuming my model contains data, I have myapp/views.py:
>
> from django.template import RequestContext
> from django.shortcuts import render
> from .models import History
> import datetime
>
> def live_view(request):
> context = RequestContext(request)
> plays_list = History.objects.filter(date=datetime.date(2016,04,22))
> context_list = {'plays':plays_list}
> return render(request,'live.html',context_list)
>
> myapp/templates/live.html:
>
> {% extends 'base.html' %}
> {% block content %}
> {% for key, value in context_list.items %}
> {{ value }}
> {% endfor %}
> {% endblock %}
>

You probably want {% for key, value in plays.items %} since there probably
isn't a context variable called {{ context_list }}.

Install the Django-debug-toolbar. It'll tell you everything that's
available in the template context and provide what templates were actually
rendered on every page load, along with other cool stuff you didn't even
know you needed to know.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWBcwjYbV9s0e8Mjr3BO7GDXCYVUW1qh8zHxDE1u1HNow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Why is my Django template not displaying?

2016-06-03 Thread Dave N
Assuming my model contains data, I have myapp/views.py:

from django.template import RequestContextfrom django.shortcuts import 
renderfrom .models import Historyimport datetime
def live_view(request):
context = RequestContext(request)
plays_list = History.objects.filter(date=datetime.date(2016,04,22))
context_list = {'plays':plays_list}
return render(request,'live.html',context_list)

myapp/templates/live.html:

{% extends 'base.html' %}{% block content %}{% for key, value in 
context_list.items %}
{{ value }}{% endfor %}{% endblock %}

myapp/urls.py:

from myapp.views import live_view
urlpatterns = [url(r'^live/$', live_view, name="live"),]


The output is a page that renders only the base.html template, with no content 
in the body. What's wrong with my view function or template rendering? Should I 
be inheriting from TemplateView?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d42cb230-a86d-4efc-bbe6-42c513227784%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.