python - Trying to Render Link From Model Into Img Tag HTML -


models.py:

class product(models.model):     product_name = models.charfield(max_length=100)     price = models.floatfield()     weight = models.floatfield()     image_link = models.urlfield(max_length=500, default="http://polyureashop.studio.crasman.fi/pub/web/img/no-image.jpg")     description = models.charfield(max_length=500)     seller = models.foreignkey('login_app.user')     reviews = models.manytomanyfield('login_app.user', related_name="reviews")     cart = models.manytomanyfield('login_app.user', related_name="carted")     created_at = models.datetimefield(auto_now_add=true)     updated_at = models.datetimefield(auto_now=true)     objects = productmanager() 

views.py:

def productdetails(request, product_id):     try:         request.session['user_id']     except keyerror:         return redirect("/")     product = product.objects.get(id = product_id)     print product     #users = user.objects.filter(joiners = plan_id).all()     context = {     'product': product,     #"user":users,     }     return render(request, 'commerce/productdetails.html', context) 

html:

<img src="{{product.image_link|urlize}}" alt="image not found"> 

whenever run output on webpage is: https://pisces.bbystatic.com/bestbuy_us/images/products/5190/5190001_sa.jpg;maxheight=460;maxwidth=460" alt="image not found">

use this

<img src="{{ product.image_link }}" alt="image not found"> 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -