Hi guys, I just want to know how to access and load the data associated to
a primary key in a template.

models.py

class Team_Region(models.Model):
    name = models.CharField(max_length=50)

    # String representation
    def __str__(self):
        return self.name



class Team_Name(models.Model):
    t_name = models.CharField(max_length=100)
    logo = models.ImageField(upload_to='team_logos', blank=True)
    region_member = models.ForeignKey(Team_Region, related_name='regions')


    def __str__(self):
        return self.t_name + ' - ' + str(self.region_member)




views.py

class TeamRegionListView(ListView):
    context_object_name = 'regions_listview'
    model = Team_Region
    template_name = 'dota_teams/team_regions_list.html'


team_regions_list.html

{% block body_block %}

    <div class="row">
        {% for region in regions_listview %}
            <div class="col-sm-6 col-lg-4">
                <a href="{{ region.id }}" class="thumbnail">{{ region.name
}}</a>
            </div>
        {% endfor %}
    </div>

{% endblock %}


What I want to achieve is to load the teams' logos and names when the
region name link is clicked in the team_regions.html. The teams that will
only be displayed in the template are the teams part of the specific ID
from Team_Region. Say, region is NA, I want all teams under NA to be
displayed in the template.

Not sure how to do this using ListView.

Any suggestions?


TIA

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA6wQLLOPMnwZKpcXsx99GUsAr2f-mS8W6C_nQd1EA-OHBa_2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to