我有个问题:
DoesNotExist at /products//
Product matching query does not exist.
Request Method: GET
Django Version: 1.4
Exception Type: DoesNotExist
Exception Value:
Product matching query does not exist.
Exception Location: /Library/Python/2.7/site-packages/Django-1.4-py2.7.egg/django/db/models/query.py in get, line 366
Python Executable: /usr/bin/python
Python Version: 2.7.1
vews.py
def SpecificProduct(request, productslug):
product = Product.objects.get(slug=productslug)
context = {'product': product}
return render_to_response('singleproduct.html',
context, context_instance=RequestContext(request))
单品.html
{% extends "base.html" %}
{% block content %}
<div id = "singleproduct">
<p>Name: {{ product }}</p>
<p>Description: {{ product.en_description }}</p>
<p>Description: {{ product.sp_description }}</p>
</div>
{% endblock %}
网址.py
(r'^products/(?P<productslug>.*)/$', 'zakai.views.SpecificProduct'),
模型.py
class Product(models.Model):
en_name = models.CharField(max_length=100)
sp_name = models.CharField(max_length=100)
slug = models.SlugField(max_length=80)
en_description = models.TextField(blank=True, help_text="Describe product in english")
sp_description = models.TextField(blank=True, help_text="Describe product in spanish")
photo = ThumbnailerImageField(upload_to="product_pic", blank=True)
def __unicode__(self):
return self.en_name