Django Tutorial (Part 2) Reference URL: http://codezine.jp/article/detail/4264?p=3
If you proceed with the above tutorial in Django 1.6 ...
#Abbreviation
from django.views.generic.simple import direct_to_template
#Abbreviation
def item_page_display(request, item_id):
item = get_object_or_404(Item, id=item_id)
return direct_to_template(request, 'page/item.html', extra_context = {'item': item })
Then, ImportError of direct_to_template will appear, so Consider using TemplateView. Reference URL: http://stackoverflow.com/questions/11005733/moving-from-direct-to-template-to-new-templateview-in-django
However, AttributeError:'function' object has no attribute'get' happened in process_response in site-packages / django / middleware / clickjacking.py, so I don't know. Import and use render and render_to_response that work similar to direct_to_template.
#Abbreviation
from django.shortcuts import render, render_to_response
from django.template import RequestContext
#Abbreviation
def item_page_display(request, item_id):
item = get_object_or_404(Item, id=item_id)
return render_to_response('page/item.html', {'item':item}, context_instance=RequestContext(request))
#Or, simpler, return render(request, 'page/item.html', {'item': item})
Reference URL: https://groups.google.com/forum/#!topic/django-users/ZuDi-iqd1Xk
Now the product screen is displayed.
Recommended Posts