Django- disallow url in robots.txt that contains variable

In my App I use an API to handle likes for blog posts. The urls are structured like

path('post/<int:pk>/<slug:slug>/', views.DetailPostView, name='post-detail'),
path('post/<int:pk>/like', PostLikeToggle.as_view(), name='like-toggle'),
path('api/post/<int:pk>/like', PostLikeAPIToggle.as_view(), name='like-api-toggle'),

The issue is google search console is giving me errors because it is trying to index the likes url and not the true url.

How would I prevent the likes URL's from being index by google as I cannot find a way to pass variables in robots.txt or is there a different way to prevent these pages from being indexed.

Back to Top