This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// api/src/Entity/User.php | |
namespace App\Entity; | |
use ApiPlatform\Core\Annotation\ApiResource; | |
use Symfony\Component\Serializer\Annotation\Groups; | |
/** | |
* @ApiResource( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// src/Serializer/UserContextBuilder.php | |
namespace App\Serializer; | |
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface; | |
use Symfony\Component\HttpFoundation\Request; | |
use App\Entity\User; | |
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; | |
final class UserContextBuilder implements SerializerContextBuilderInterface |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def arttir(sayi): | |
return sayi*5+2 | |
print(arttir(4)) | |
#out: 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arttir = lambda sayi : sayi*5+2 | |
print(arttir(4)) | |
# out: 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toplama = lambda sayi_1, sayi_2 : sayi_1+sayi_2 | |
print(toplama(11,11)) | |
# out: 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
liste = [1,2,3,4] | |
def arttir(sayi): | |
return sayi *5+2 | |
print(list(map(arttir, liste))) | |
# out: [7, 12, 17, 22] | |
# yada lambda terimi ile kullanalım | |
print(list(map(lambda sayi: sayi *5+2, liste))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
liste = [1,2,3,4,5,6,7,8,9,10] | |
def cift(sayi): | |
return sayi%2==0 | |
print(list(filter(cift, liste))) | |
# out: [2, 4, 6, 8, 10] | |
# yada lambda terimi ile kullanalım | |
print(list(filter(lambda sayi: sayi%2==0, liste))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
liste = [1,2,3,4,5] | |
def carp(mevcut, siradaki): | |
return mevcut*siradaki | |
print(reduce(carp, liste)) | |
#out: 120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Company(models.Model): | |
name = models.CharField(max_length=200, unique=True) | |
email = models.EmailField(unique=True) | |
www = models.URLField() | |
linkedin = models.URLField(null=True,) | |
pub_date = models.DateTimeField(null=True) | |
created_at = models.DateTimeField(auto_now_add=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .models import Company | |
from rest_framework import serializers | |
class CompanySerializer(serializers.ModelSerializer): | |
name = serializers.CharField(required=True, max_length=190) | |
email = serializers.EmailField(required=True, max_length=190) | |
logo = serializers.CharField(required=True, max_length=190) | |
www = serializers.URLField(required=True, max_length=190) | |
linkedin = serializers.CharField(required=False, max_length=190) |