Skip to content
Advertisement

Capturing values from url in post request in Django

I want to capture url values from a url into my views in a post request.

My urls.py looks like below

from django.urls import path from . import views as projects_views

JavaScript

and I want to capture the value project_id in my ListCreateAPIView. Get call works fine.

My views.py looks like below

JavaScript

How can this be done?

Advertisement

Answer

Use self.kwargs["project_id"] to get the project_id in perform_create() method,

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement