<a href="{% url 'clubs:club_home_with_pk' pk=club.pk %}">
urlpatterns = [
path('', views.club_home, name='club_home'),
path('<int:pk>/', include([
path('home/', views.club_home, name='club_home_with_pk'),
path('teams/', views.TeamInfo.as_view(), name='teams'),
])),
<li><a class="nav-link" href="{% url 'clubs:club_home' %}">Home</a></li>
<li><a class="nav-link" href="{% url 'clubs:teams' %}">Team</a></li>
<li><a class="nav-link" href="{% url 'clubs:pitches' %}">Pitches</a></li>
<li><a class="nav-link" href="{% url 'clubs:memberships' %}">Memberships</a></li>
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):
form = TeamForm()
user = ClubInfo.objects.filter(user=request.user).first()
teams = Team.objects.filter(club_id=user.pk)
return Response({'form': form,
'teams': teams,
})
def post(self, request):
form = TeamForm(data=request.data)
user = ClubInfo.objects.filter(user=request.user).first()
teams = Team.objects.filter(club_id=user.pk)
if form.is_valid():
form.save()
return Response({'form': form,
'teams': teams
})
--
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/KsvZHK1z6BI/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/c508e2ee-d73a-4a02-923d-d033e467efe3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sé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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHZR7JdWHnLsaE8a4z2Bjdj4qQJJoee%3D_f4C_MVibQw6pMOAZQ%40mail.gmail.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/CABXH83qsJurb03-JZjM2jgg5j1Q24mGAKXE9ZBdSLFRLO3Q0Kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.