I have the following URL:
url(r'^member/(?P<member_id>\d+_([\w-]+){22})/join/?$', views.ActivityJoinView.as_view(),
name='member_join'),
Within my DRF serializer create
method I need to get access to member_id
.
I have tried this:
class JoinListSerializer(serializers.ModelSerializer):
class Meta:
model = Join
fields = ("id", )
def create(self, validated_data):
print(self.context['request'].query_params)
I've also tried validated_data.get('member_id', None)
But still get bank/none! How can I get member_id
inside my create method?
在create
方法中,您应该能够访问传递给呈现端点的视图的参数,
self.context['view'].kwargs.get('member_id')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.