khashashin
khashashin

Reputation: 1137

wagtail AttributeError at /

My project tree: enter image description here

home_page.html:

{% extends "base.html" %}
{% block title %}
Treichle-Cup
{% endblock %}
{% block body_class %}template-homepage{% endblock %}
{% block content %}
{% endblock %}

team_rooster.html

{% extends 'base.html' %}
{% load wagtailcore_tags %}

{% block content %}
<div class="container">
  {% for team in teams %}
  <div class="row">
    <table border="2" width="100%">
      <tbody>
        <tr>
          <th colspan="5">{{team.team_name}}</th>
        </tr>
        <tr>
          <td colspan="2" rowspan="3">{{team.team_logo}}</td>
          <th colspan="3">Staff</th>
        </tr>
        <tr>
          <th>Name</th>
        </tr>
        <tr>
          <td>{{team.staff.name}}</td>
        </tr>
      </tbody>
    </table>
  </div>
  {% endfor %}
</div>

{% endblock %}

It's hard to find out how wagtail view functionality works. My goal is just to render my team_rooster.html if i go to www.mysite.com/team-rooster

i get an attributeerrof when i try to render my template

here is a traceback log http://dpaste.com/3TH3WT5

{% load static wagtailcore_tags %}

  <div class="left-side sticky-left-side">
    <div class="logo-icon text-center custom-nav">
      <a href="{% pageurl team_rooster %}"><i class="fa fa-group fa-2x"></i></a>
      <span style="top: 76px">Teams</span>
    </div>
</div>

i tried with {% pageurl page.team_rooster %} but got same error

My model has following classes

class Staff(StructBlock):
    photo = ImageChooserBlock(required=False)
    position = ChoiceBlock(choices=[
        ('headcouch', 'Headcouch'),
        ], icon='cup')

    class Meta:
        icon = 'plus'

class Spieler(StructBlock):
    photo = ImageChooserBlock(required=False)
    position = ChoiceBlock(choices=[
        ('th', 'TH'),
        ], icon='cup')
    jahrgang = IntegerBlock(required=True)

    class Meta:
        icon = 'user'

class TeamRooster(Page):
    team_name = models.CharField(max_length=100)
    staff = StreamField([
        ('staff', CardsBlock(Staff(), icon="plus")),
    ], blank=True)
    spieler = StreamField([
        ('spieler', CardsBlock(Spieler(), icon="user")),
    ], blank=True)    

    content_panels = [
        FieldPanel('team_name', classname="col12"),
        ImageChooserPanel('team_logo'),
        StreamFieldPanel('staff'),
        StreamFieldPanel('spieler'),
    ]

    def __str__(self):
        return self.team_name

Upvotes: 0

Views: 238

Answers (1)

LB Ben Johnston
LB Ben Johnston

Reputation: 5196

To get the URL of the current page from within its own template simply do:

{% pageurl self %}

OR

{% pageurl page %}

Note: You must have loaded the wagtailcore_tags eg. {% load wagtailcore_tags %}

Upvotes: 1

Related Questions