django rest framework invalid literal for int() with base 10: -


the following restful api failed error have no idea going on there.

here construct of serializer, model , url pattern.

serializers.py

class patientdataserializer(serializers.modelserializer):     class meta:         model = patientdata         fields = (             'data_id',             'data_type',             'session_id',             'user_id',             'start_time',             'time_elapsed',             'data_file_url'         )         lookup_field='user_id' 

models.py

class patientdata(models.model):     class meta:         managed = false         db_table = "patient_data_list"      data_id = models.positiveintegerfield(db_column="data_id", primary_key=true)     data_type = models.charfield(db_column="patient_data_type", max_length=255)     session_id = models.positiveintegerfield(db_column="session_id")     user_id = models.positiveintegerfield(db_column="user_id")     start_time = models.datetimefield(db_column="start_time")     time_elapsed = models.integerfield(db_column="time_elapsed")     data_file_url = models.integerfield(db_column="data_file_url")   

urls.py

 url(r'^patients/data/(?p<user_id>[0-9]+)/$', restapiviews.patientdatalistview.as_view()), 

restapiviews.py

class patientdatalistview(generics.listapiview):     queryset = patientdata.objects.all()     serializer_class = patientdataserializer     lookup_field='user_id' 

the error appears when tried access localhost:8080/api/patient/data/1/ url

this error means trying cast empty string or unicode int.

i able run code locally , suspect happens because in database there empty value in fields should integers. drf integerfield's to_representation method requires makes simple casting int, , doesn't check empty values. please check data in manner, , if not point paste whole traceback error.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -