Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试将django oscar产品传递到自定义模板_Python_Django_Django Oscar - Fatal编程技术网

Python 尝试将django oscar产品传递到自定义模板

Python 尝试将django oscar产品传递到自定义模板,python,django,django-oscar,Python,Django,Django Oscar,我正在使用django oscar应用程序的分叉版本开发一个定制模板,以定制模型 首先,我试图显示product表中所有产品的列表。我查看了django oscar模板,但由于它们依赖于大量定制的tempaltetag,我发现它太复杂了,无法重写所有内容来使用我的模型 这是我的视图中的内容。py: def product(request): template = loader.get_template('/home/mysite/django_sites/my_site/main_pag

我正在使用django oscar应用程序的分叉版本开发一个定制模板,以定制模型

首先,我试图显示product表中所有产品的列表。我查看了django oscar模板,但由于它们依赖于大量定制的tempaltetag,我发现它太复杂了,无法重写所有内容来使用我的模型

这是我的视图中的内容。py:

def product(request):
    template = loader.get_template('/home/mysite/django_sites/my_site/main_page/templates/main_page/product.html')
    prodlist = Product.objects.all()
    return HttpResponse(template.render({}, request), context={'prodlist': prodlist})
以及我在模板中尝试和显示它的代码

{% for instance in prodlist%}
    <li>{{ instance.name }}</li>
{% endfor %}
/产品对应于my URL.py中的我的产品视图

这是我根据以下教程和其他答案做出的最佳猜测。我做错了什么?

HttpResponse没有上下文参数。 似乎需要将上下文添加到渲染中

尝试:


嗯,谢谢你!虽然现在我在/product/==换行==列目录\产品集合\ id不存在==换行==行1:…\更新了,目录\产品。是否可折扣,目录…是否运行了迁移?python manage.py makemigrations和python manage.py migrate?我以前做过。我刚刚再次运行makemigrations,它显示未检测到任何更改。与我如何分叉应用程序有关吗?-ope,运行迁移,我遇到了错误,将继续工作!
TypeError at /product/ 
__init__() got an unexpected keyword argument 'context'
context={'prodlist': prodlist}
return HttpResponse(template.render(context))