<h2>Our Clubs</h2>
{% for club in all_clubs %}
<a href="{% url 'clubs:club_home_with_pk' pk=club.pk %}">
<li>{{ club.club_name }}</li>
</a>
{% endfor %}
urlpatterns = [
path('', views.club_home, name='club_home'),
path('<int:pk>/', views.club_home, name='club_home_with_pk'),
path('teams/', views.TeamInfo.as_view(), name='teams'),
]
views.py
def club_home(request, pk=None):
if pk:
club = ClubInfo.objects.filter(pk=pk)
club_posts = ClubPosts.objects.filter(club_id=club[0])
elif request.user.is_authenticated:
club = ClubInfo.objects.filter(user=request.user)
club_posts = ClubPosts.objects.filter(club_id=club[0])
# photo = model.club_logo.ImageField(storage=profile_pics)
args = {'club': club,
'club_posts': club_posts
}
return render(request, 'club_home_page.html', args)class TeamInfo(APIView):
renderer_classes = [TemplateHTMLRenderer]
template_name = 'teams.html'
def get(self, request):
serializer = TeamSerializer()
user = ClubInfo.objects.filter(user=request.user).first()
teams = Team.objects.filter(club_id=user.pk)
return Response({'serializer': serializer,
'teams': teams,
})
club_main_page.html
***navbar on club home page to get to other pages, I know I need to include <pk> into the URL and I need to pass this argument into the href of this URL but as need to figure out the view before adding this ***<li><a class="navbar-link" href="{% url 'clubs:teams' %}">Team</a></li>
Any idea what I need to add into the view to allow for this. I would really appreciate any help as I've been stuck on this for weeks now.
Thanks
GavinSéanadh Ríomhphoist/
Email Disclaimer
Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin é. Is féidir tuilleadh a léamh anseo.
This e-mail and any files transmitted with it are confidential and are intended solely for use by the addressee. Read more here.
urlpatterns = [
path('', views.club_home, name='club_home'),
path('<int:pk>/', include(club_home_urls, namespace='club_home')),
]
--
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...@googlegroups.com.
To post to this group, send email to django...@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/3465a2fc-347a-4096-b037-83be9b57d8a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANuyGV1Dr6NUtk%3DNm3Bh9Ev%2Bvov%2B35_i0Q%2BfL6-2xP%3D0-DsuAg%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/OR2enuwbwsg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@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/CAFab_C9Af6v%3Dqpte7jAFd7jRFwN42G89mpu4xQeHg1fZTUbZYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.