- return get_object_or_404(
- Tag,
- category=self.kwargs['category'],
- slug=self.kwargs['slug']
- )
+ try:
+ return get_object_or_404(
+ Tag,
+ category=self.kwargs['category'],
+ slug=self.kwargs['slug']
+ )
+ except Http404:
+ if self.method == 'PUT':
+ return Tag(
+ category=self.kwargs['category'],
+ slug=self.kwargs['slug']
+ )
+ else:
+ raise
+
+ def post(self, request, **kwargs):
+ data = json.loads(request.POST.get('data'))
+ desc = data['description_pl']
+ obj = self.get_object()
+ obj.description_pl = desc
+ obj.save(update_fields=['description_pl'], quick=True)
+ return Response({})