0
我目前收到試圖去網址... /調查/產品時,這個錯誤/Django的失蹤url參數>視圖
TypeError at /polls/products/
productindex() takes exactly 2 arguments (1 given)
我已經測試附加到我相信一個查看URL作品很好,所以我猜測我的觀點有問題。
models.py
class Product(models.Model):
product_name = models.CharField(max_length=200)
product_description = models.TextField()
def __unicode__(self):
return self.product_name
class Image(models.Model):
product_image = models.ForeignKey(Product)
image = models.ImageField(upload_to='image')
views.py
def productindex(request, product_image_id):
product = get_object_or_404(Product, pk=product_image_id)
return render(request, 'polls/products.html', {'product': product})
urls.py
from django.conf.urls import patterns, url
from polls import views
urlpatterns = patterns('',
url(r'products/$', views.productindex, name='productindex'),
)