Nov-03-2021, 05:08 PM
Hello , my name luigi from italy age 39 old year .. my studing hobby web programming for django web framework.
my problem not work in template <title>blcok code and other row.
only model photo .. not working model Album in album_detail.html
showing :
{{album.title}}
idea? how to fixed ?? django 3.2
my problem not work in template <title>blcok code and other row.
only model photo .. not working model Album in album_detail.html
showing :
{{album.title}}
idea? how to fixed ?? django 3.2
"""
album.html
"""
{% extends "site/common.album.html" %}
{% load static %}
{% block title %} Album {% endblock %}
{% block content %}
<div class="row" >
{% for albumData in album %}
<div class="col-sm-4" style="padding-top:30px;">
<div class="card">
<div class="card-body">
<h5 class="card-title">{{albumData.titolo }}</h5>
<p class="card-text">{{albumData.descrizione }}</p>
<a href="{{albumData.id }}/">Accedi</a>
</div>
</div>
</div>
{% empty %}
<div>No album</div>
{% endfor %}
</div>
{% endblock content %}
"""
album_detail.html
"""
{% extends "site/common.photo.html" %}
{% load static %}
{% block title %} Foto {% endblock title %}
{% block content %}
<h1 class="display-1 text-center">Foto</h1>
<h3>{{album.titolo}}</h3>
<div id="photo">
<ul class="album album_1">
{% for photoData in photo %}
<li><figure class="figure">
<a href="/public/{{photoData.foto.large }}" class="big"><img src="/public/{{photoData.foto.thumbnail }}" class="figure-img img-fluid rounded big" alt="{{photoData.titolo }}" title="{{photoData.descrizione }}"></a>
<figcaption class="figure-caption text-center">{{photoData.descrizione }}</figcaption>
</figure>
</li>
{% empty %}
<div>No photo</div>
{% endfor %}
</ul>
</div>
</div>
{% endblock content %} """
views.py
"""
from django.shortcuts import render
from .models import Album, Photo
def view_album(request):
album = Album.objects.all().order_by('creato')
context = {'album': album}
return render(request, "album.html", context)
def view_photo(request, album_id):
photo = Photo.objects.filter(album_id=album_id).all().order_by('creato')
context = {'photo': photo}
return render(request, "album_detail.html", context)
