嘿,我希望有人能幫助我。Django從管理員的產品名稱連接圖像
我正在一個電子商務網站上工作,我可以通過django添加每個產品從管理數據庫,但我不能添加圖像,目前代碼添加到每個產品相同的圖像。
{% for Product in oldProducts %}
<div class="col-lg-4">
<img class="img-circle" src="{% static "ecommerce/img/weightgain2.png" %}" alt="Generic placeholder image" width="140" height="140">
<h2>{{ Product.Name }}</h2>
<p>{{ Product.Price }} </br> {{ Product.Description }}</p>
<form method='POST' action="{% url 'ecommerce:addbasket' %}">
{% csrf_token %}
<input type="hidden" name="stuffNum" value="{{ Product.ProductID }}">
<input type="hidden" name="stuffName" value="{{ Product.Name }}">
<input type="hidden" name="stuffPri" value="{{ Product.Price }}">
<input type="hidden" name="stuffDesc" value="{{ Product.Description }}">
<button class="btn btn-default" type="submit">Add To Basket</button>
</form>
</div><!-- /.col-lg-4 -->
{% endfor %}
我怎樣才能讓每一個產品採取不同的圖像具有相同的名稱作爲產品?
class Product(models.Model):
ProductID = models.AutoField(db_column='ProductId', primary_key=True) # Field name made lowercase.
Name = models.CharField(db_column='Name', max_length=255, blank=True, null=True) # Field name made lowercase.
Price = models.TextField(db_column='Price', blank=True, null=True) # Field name made lowercase. This field type is a guess.
Description = models.TextField(db_column='Description', blank=True, null=True) # Field name made lowercase.
Image = models.TextField(db_column='Image', blank=True, null=True) # Field name made lowercase.
請給出您的模型 –
那就是產品的型號 – Daniiii