0

{% for film in regista.film_set.all %}「レジスタ」( )と「続編」( )の「フィルム」を「あんの」さんに注文したいのですが{% for sequel in film.sequels.all %}、どうすればいいのかわかりません....ありがとうございます...

ここにmodels.py

class Anno( models.Model ):
    anno = models.CharField( max_length=4 )
    def __unicode__(self):
        return self.anno
    class Meta:
        verbose_name_plural = "Anni"

class Film( models.Model ):
    titolo = models.CharField( max_length=39 )
    trama = models.TextField( max_length=1000 )
    anno = models.ForeignKey( Anno )
    registi = models.ManyToManyField( Regista )
    generi = models.ManyToManyField( Genere_Film )
    sequels = models.ManyToManyField( "self", blank=True )
    def __unicode__(self):
        return self.titolo + " " + self.trama
    class Meta:
        verbose_name_plural = "Films"

ここにviews.py

def film(request, id):
    film = get_object_or_404( Film, pk=id )
    return render_to_response('Film.html', { 'film': film })

こちら Film.html

{{ film.titolo }}
{% for generi in film.generi.all %}{{ generi.genere}}{% endfor %}
{{ film.anno }}
{{ film.trama }}
{% for regista in film.registi.all %}
  {{ regista.nome }} {{ regista.cognome }}
  {% for film in regista.film_set.all %}
    {{ film.titolo }}
  {% endfor %}
{% endfor %}
{% for sequel in film.sequels.all %}
  {{ sequel.titolo }}
{% endfor %}
4

1 に答える 1

0

class Metaで、指定できますordering

class Anno( models.Model ):
    anno = models.CharField( max_length=4 )
    def __unicode__(self):
        return self.anno
    class Meta:
        verbose_name_plural = "Anni"
        ordering = ('anno', )
于 2013-06-14T15:20:21.383 に答える