mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Check for Django version
This commit is contained in:
parent
604b9004c6
commit
a6c73c6f90
|
@ -15,6 +15,9 @@ import copy
|
|||
import datetime
|
||||
import inspect
|
||||
import types
|
||||
|
||||
import django
|
||||
|
||||
from decimal import Decimal
|
||||
from django.core.paginator import Page
|
||||
from django.db import models
|
||||
|
@ -1081,7 +1084,10 @@ class ModelSerializer(Serializer):
|
|||
self.save_object(related)
|
||||
elif isinstance(related, list):
|
||||
# Many to One/Many
|
||||
if django.VERSION >= (1, 9):
|
||||
getattr(obj, accessor_name).add(*related, bulk=False)
|
||||
else:
|
||||
getattr(obj, accessor_name).add(*related)
|
||||
else:
|
||||
# Reverse FK or reverse one-one
|
||||
setattr(obj, accessor_name, related)
|
||||
|
|
Loading…
Reference in New Issue
Block a user