serializer save returns ​ DoesNotExis, MultipleObjectsReturned

15 views
Skip to first unread message

Nazish Akhtar

unread,
Apr 29, 2020, 11:50:05 AM4/29/20
to Django REST framework
While saving serializer I am getting DoesNotExist , MultipleObjectsReturned . However objects are being saved in DB but signals such as post_save does not work. Custom Signal also does not work.

Here is detailed error:

1
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_check_column_name_clashes', '_check_constraints', '_check_field_name_clashes', '_check_fields', '_check_id_field', '_check_index_together', '_check_indexes', '_check_local_fields', '_check_long_column_names', '_check_m2m_through_same_relationship', '_check_managers', '_check_model', '_check_model_name_db_lookup_clashes', '_check_ordering', '_check_property_name_related_field_accessor_clashes', '_check_single_primary_key', '_check_swappable', '_check_unique_together', '_do_insert', '_do_update', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_get_unique_checks', '_meta', '_perform_date_checks', '_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val', '_state', 'car_category', 'car_id', 'car_model', 'car_owner', 'car_owner_id', 'car_registration_no', 'carimageverification', 'carverification', 'chassis_number', 'check', 'clean', 'clean_fields', 'color', 'date_error_message', 'delete', 'engine_number', 'from_db', 'fuel_type', 'full_clean', 'get_car_category_display', 'get_deferred_fields', 'get_fuel_type_display', 'get_manufacturer_display', 'get_owner_serial_number_display', 'get_ownership_type_display', 'km_ran', 'manufacturer', 'objects', 'owner_serial_number', 'ownership_type', 'pk', 'prepare_database_save', 'rc_back_image', 'rc_front_image', 'refresh_from_db', 'save', 'save_base', 'serializable_value', 'unique_error_message', 'validate_unique', 'verified']
1
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_check_column_name_clashes', '_check_constraints', '_check_field_name_clashes', '_check_fields', '_check_id_field', '_check_index_together', '_check_indexes', '_check_local_fields', '_check_long_column_names', '_check_m2m_through_same_relationship', '_check_managers', '_check_model', '_check_model_name_db_lookup_clashes', '_check_ordering', '_check_property_name_related_field_accessor_clashes', '_check_single_primary_key', '_check_swappable', '_check_unique_together', '_do_insert', '_do_update', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_get_unique_checks', '_meta', '_perform_date_checks', '_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val', '_state', 'car_category', 'car_id', 'car_model', 'car_owner', 'car_owner_id', 'car_registration_no', 'carimageverification', 'carverification', 'chassis_number', 'check', 'clean', 'clean_fields', 'color', 'date_error_message', 'delete', 'engine_number', 'from_db', 'fuel_type', 'full_clean', 'get_car_category_display', 'get_deferred_fields', 'get_fuel_type_display', 'get_manufacturer_display', 'get_owner_serial_number_display', 'get_ownership_type_display', 'km_ran', 'manufacturer', 'objects', 'owner_serial_number', 'ownership_type', 'pk', 'prepare_database_save', 'rc_back_image', 'rc_front_image', 'refresh_from_db', 'save', 'save_base', 'serializable_value', 'unique_error_message', 'validate_unique', 'verified']

Here is the code and error, better formatted. Any help would be appreciated

Carl Nobile

unread,
Apr 29, 2020, 1:02:37 PM4/29/20
to django-res...@googlegroups.com
It looks like you are, for some reason, returning a dump of the objects on the model, not the data. Something is messed up in your code. You might want to post the sterilizer create and update methods you created.

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/b143e59c-6b1f-43ed-b3ad-473392cbd609%40googlegroups.com.


--
-------------------------------------------------------------------------------
Carl J. Nobile (Software Engineer)
carl....@gmail.com
-------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages