예제 #1
0
    def get_or_create_object(self):
        me = Friend.objects.filter(me=True).first()
        if not me:
            x = Friend.random_position()
            y = Friend.random_position()
            me = Friend(x=x, y=y, me=True)
            me.save()
            me.generate_friends()

        return me
예제 #2
0
    def get_or_create_object(self):
        me = Friend.objects.filter(me=True).first()
        if not me:
            x = Friend.random_position()
            y = Friend.random_position()
            me = Friend(x=x, y=y, me=True)
            me.save()
            me.generate_friends()

        return me
예제 #3
0
    def get(self, request):
        Friend.objects.all().delete()

        x = Friend.random_position()
        y = Friend.random_position()
        me = Friend(x=x, y=y, me=True)
        me.save()
        me.generate_friends()

        me_serialized = FriendSerializer(me)

        return Response(me_serialized.data)
예제 #4
0
    def get(self, request):
        Friend.objects.all().delete()

        x = Friend.random_position()
        y = Friend.random_position()
        me = Friend(x=x, y=y, me=True)
        me.save()
        me.generate_friends()

        me_serialized = FriendSerializer(me)

        return Response(me_serialized.data)