Fix author bug
This commit is contained in:
parent
9e7a950088
commit
1849166bae
|
|
@ -202,11 +202,18 @@ class NewsBackOfficeBaseSerializer(NewsBaseSerializer):
|
|||
|
||||
def create(self, validated_data):
|
||||
slugs = validated_data.get('slugs')
|
||||
|
||||
if slugs:
|
||||
if models.News.objects.filter(
|
||||
slugs__values__contains=list(slugs.values())
|
||||
).exists():
|
||||
raise serializers.ValidationError({'slugs': _('News with this slug already exists.')})
|
||||
|
||||
request = self.context.get("request")
|
||||
if request and hasattr(request, "user"):
|
||||
user = request.user
|
||||
validated_data['created_by'] = user
|
||||
|
||||
return super().create(validated_data)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user