lass Cruski(models.Model):
name = models.CharField(max_length=40)
description = models.TextField(default='Описание кружка')
price = models.IntegerField(default=0)
def __str__(self):
return self.name
class Vospitately(models.Model):
fio = models.CharField(max_length=40)
dolshnost = models.CharField(max_length=80, default='Должность..')
image = models.ImageField()
vospet_crushek = models.ForeignKey(Cruski)
def __str__(self):
return self.fio
def kruzhki(request):
q = Cruski.objects.all()
p = Vospitately.objects.filter(vospet_crushek_id=?)
return render(request,'krushki.html',{'kruzki':q, 'vospitately':p})
{% block kruzhki %}
{% for krug in kruzki %}
<p><b>{{ krug.name }}</b></p>
{% for vospet in vospitately %}
<p> {{ vospet.fio }}</p>
{% endfor %}
<p>{{ krug.description }}</p>
<p>{{ krug.price }}</p>
{% endfor %}
class Vospitately(models.Model):
fio = models.CharField(max_length=40)
dolshnost = models.CharField(max_length=80, default='Должность..')
image = models.ImageField()
vospet_crushek = models.ForeignKey(Cruski', related_name='vospitately')
def __str__(self):
return self.fio
def kruzhki(request):
q = Cruski.objects.all()
return render(request,'krushki.html',{'kruzki':q})
{% block kruzhki %}
{% for krug in kruzki %}
<p><b>{{ krug.name }}</b></p>
{% for vospet in krug.vospitately.all %}
<p> {{ vospet.fio }}</p>
{% endfor %}
<p>{{ krug.description }}</p>
<p>{{ krug.price }}</p>
{% endfor %}
class Cruski(models.Model):
name = models.CharField(max_length=40)
description = models.TextField(default='Описание кружка')
price = models.IntegerField(default=0)
def __str__(self):
return self.name
class Vospitately(models.Model):
fio = models.CharField(max_length=40)
dolshnost = models.CharField(max_length=80, default='Должность..')
image = models.ImageField()
vospet_crushek = models.ForeignKey(Cruski, related_name='vospitately')
def __str__(self):
return self.fio
def kruzhki(request):
q = Cruski.objects.all()
return render(request,'krushki.html',{'kruzki':q})
{% block kruzhki %}
{% for krug in kruzki %}
<p><b>{{ krug.name }}</b></p>
{% for vospet in krug.vospitately.all %}
<p> {{ vospet.fio }}</p>
{% endfor %}
<p>{{ krug.description }}</p>
<p>{{ krug.price }}</p>
{% endfor %}