I used uuid for id, but now i want to turn into slug in one of my views
model:
class Club(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
slug = models.SlugField(null=True)
url:
urlpatterns = [path("slug:slug", RankClubView.as_view(), name="ranking_club"),]
View (RankView inherited from TemplateView):
class RankClubView(RankView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
club = Club.objects.filter(pk=self.kwargs["pk"]).first()
context["club"] = club
context["all_players"] = context["all_players"].filter(club=club)
return context
template:
<a href="{% url 'Ranking:ranking_club' club.id %}">{{club.name}}</a>
This is giving me this error:
NoReverseMatch at /
Reverse for ‘ranking_club’ with arguments ‘(‘cdplaflorida’,)’ not found. 1 pattern(s) tried: [‘ranking/slug:slug\Z’]
So, how can i keep the uuid for the id and use slug for url?
Thanks