from rest_framework import serializers
from uchicagohvz.game.models import *

class KillSerializer(serializers.ModelSerializer):
	class Meta:
		model = Kill
		fields = ('id', 'killer', 'victim', 'location', 'date', 'points')

	killer = serializers.SerializerMethodField('get_killer')
	victim = serializers.SerializerMethodField('get_victim')
	location = serializers.SerializerMethodField('get_location')

	def get_killer(self, obj):
		return obj.killer.display_name

	def get_victim(self, obj):
		return obj.victim.display_name

	def get_location(self, obj):
		if not (obj.lat and obj.lng):
			return None
		return (obj.lat, obj.lng)


from rest_framework import serializers
from uchicagohvz.game.models import *

class KillSerializer(serializers.ModelSerializer):
	class Meta:
		model = Kill
		fields = ('id', 'killer', 'victim', 'location', 'date', 'points')

	killer = serializers.SerializerMethodField()
	victim = serializers.SerializerMethodField()
	location = serializers.SerializerMethodField()

	def get_killer(self, obj):
		return obj.killer.display_name

	def get_victim(self, obj):
		return obj.victim.display_name

	def get_location(self, obj):
		if not (obj.lat and obj.lng):
			return None
		return (obj.lat, obj.lng)


Remove default method_name in SerializerMethodField
Remove default method_name in SerializerMethodField
  from rest_framework import serializers
  from uchicagohvz.game.models import *
  
  class KillSerializer(serializers.ModelSerializer):
  	class Meta:
  		model = Kill
  		fields = ('id', 'killer', 'victim', 'location', 'date', 'points')
  
- 	killer = serializers.SerializerMethodField('get_killer')
+ 	killer = serializers.SerializerMethodField()
- 	victim = serializers.SerializerMethodField('get_victim')
+ 	victim = serializers.SerializerMethodField()
- 	location = serializers.SerializerMethodField('get_location')
+ 	location = serializers.SerializerMethodField()
  
  	def get_killer(self, obj):
  		return obj.killer.display_name
  
  	def get_victim(self, obj):
  		return obj.victim.display_name
  
  	def get_location(self, obj):
  		if not (obj.lat and obj.lng):
  			return None
  		return (obj.lat, obj.lng)
  
  
Remove default method_name in SerializerMethodField
## Code Before:
from rest_framework import serializers
from uchicagohvz.game.models import *

class KillSerializer(serializers.ModelSerializer):
	class Meta:
		model = Kill
		fields = ('id', 'killer', 'victim', 'location', 'date', 'points')

	killer = serializers.SerializerMethodField('get_killer')
	victim = serializers.SerializerMethodField('get_victim')
	location = serializers.SerializerMethodField('get_location')

	def get_killer(self, obj):
		return obj.killer.display_name

	def get_victim(self, obj):
		return obj.victim.display_name

	def get_location(self, obj):
		if not (obj.lat and obj.lng):
			return None
		return (obj.lat, obj.lng)


## Instruction:
Remove default method_name in SerializerMethodField
## Code After:
from rest_framework import serializers
from uchicagohvz.game.models import *

class KillSerializer(serializers.ModelSerializer):
	class Meta:
		model = Kill
		fields = ('id', 'killer', 'victim', 'location', 'date', 'points')

	killer = serializers.SerializerMethodField()
	victim = serializers.SerializerMethodField()
	location = serializers.SerializerMethodField()

	def get_killer(self, obj):
		return obj.killer.display_name

	def get_victim(self, obj):
		return obj.victim.display_name

	def get_location(self, obj):
		if not (obj.lat and obj.lng):
			return None
		return (obj.lat, obj.lng)

