I have created a simple service which returns the data from a single table 
based on a param in the URL as follow:
Enter code here...http://127.0.0.1:8000/api/figo?figonr=1078924300-01

output is the json:
HTTP 200 OKAllow: GETContent-Type: application/jsonVary: Accept
[
   {
        "figonr": "1078924300-01",
        "description": "F150/C+W/CC/GE201S/S/OE/SE",
        "productgroup": null
   }]


I would like to add in the json list a small dict with values like
Enter code here...{

"execution_time": "13:00"}


so the final result will be
Enter code here...[

    {
    "figonr": "1078924300-01",
    "description": "F150/C+W/CC/GE201S/S/OE/SE",
    "productgroup": null
    },
    {
    "execution_time": "13:00"
    }]



here is my serilalizer code
Enter code here...from rest_framework import serializers

from servicesapp.models import Figo
import datetime

class ServiceAppSerializer(serializers.ModelSerializer):
    ExecutionTime = serializers.SerializerMethodField()  # add field

    class Meta:
        model = Figo
        fields=('figonr','description', 'username', 'timestmp', 'ExecutionTime')

    def get_ExecutionTime(self, obj):
        # here write the logic to compute the value based on object
        george=1
        return datetime.datetime.now()




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90db9196-7cdc-44f0-a4a0-8e100c768ae5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to