class Team_Region(models.Model):
name = models.CharField(max_length=50)
# String representation
def __str__(self):
return self.name
class Team_Name(models.Model):
team_name = models.CharField(max_length=150)
logo = models.ImageField(upload_to='team_logos', blank=True)
region_member = models.ForeignKey(Team_Region, related_name='region_mem')
def __str__(self):
return self.team_name + ' - ' + str(self.region_member)
class Team_Member(models.Model):
member_name = models.CharField(max_length=150)
position = models.CharField(max_length=50)
member_of_team = models.ForeignKey(Team_Name, related_name='team_mem')
def __str__(self):
return self.member_name + ' - ' + str(self.member_of_team)
# Listview of Regions
class TeamRegionListView(ListView):
context_object_name = 'region_name'
model = Team_Region
template_name = 'dota_teams/team_region_list.html'
# DetailView of Regions
class TeamRegionDetailView(DetailView):
context_object_name = 'team_names'
model = Team_Region
template_name = 'dota_teams/team_region_detail.html'
# DetailView of Teams. Will show team members
class TeamDetailView(DetailView):
context_object_name = 'team_members'
model = Team_Region
template_name = 'dota_teams/team_detail.html'
url(r'^$', views.TeamRegionListView.as_view(), name='region_list'),
url(r'^(?P<pk>\d+)/$', views.TeamRegionDetailView.as_view(), name='region_detail'),
url(r'^(?P<pk>\d+)/(\d+)/$', views.TeamDetailView.as_view(), name='team_detail'),
<div class="row">
{% for team in team_members.region_mem.all %}
{% for member in team.team_mem.all %}
<div class="col-xs-12 col-lg-3">
<div class="thumbnail">
<h4>{{ member.member_name }}</h4>
<div class="caption">
<h5>{{ member.position }}</h5>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
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+unsubscribe@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/CAA6wQLKCC1duXTRdru67Ej0MyuvMKL17DM4QTh%2BBmxxsw%2BxeFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment