Answer the question
In order to leave comments, you need to log in
How to display data in html template?
Hello.
Please help me resolve this issue. I've watched a lot of videos, but I can't get an answer to my question.
I created a class in model.pu
class Store(models.Model):
name = models.CharField(max_length=20,verbose_name="Имя магазина" )
image = models.ImageField(upload_to = 'static/img',verbose_name="Фото")
website = models.URLField(max_length=250, verbose_name="Сайт")
def __str__(self):
return self.name
from index.models import Store
admin.site.register(Store)
<div class="container">
<h1 class="font-weight-light text-center text-lg-left mt-4 mb-0">Магазины</h1>
<hr class="mt-2 mb-5">
<div class="row text-center text-lg-left">
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" rel="nofollow" target="_BLANK" src="{{ Store.image }}" alt="">
</a>
<p> {{ Store.name }}</p>
<p> Website: {{ Store.Website }}</p>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
On the topic, you made a model and registered it in the admin panel (but who knows why in urls.py). It remains to create a method for rendering html in views.py and add paths and a method call from views to urls.py.
And so it’s worth going through the django tutorial, at least on django girls, at least the translation of the official documentation and horses with people will be safe.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question